Add method to get beam entities

This commit is contained in:
Matthew Honnibal 2017-07-29 21:59:02 +02:00
parent ec63f4fe7b
commit 27abc56e98

View File

@ -141,6 +141,23 @@ cdef class BiluoPushDown(TransitionSystem):
entities[(start, end, label)] += prob
return entities
def get_beam_parses(self, Beam beam):
parses = []
probs = beam.probs
for i in range(beam.size):
stcls = <StateClass>beam.at(i)
if stcls.is_final():
self.finalize_state(stcls.c)
prob = probs[i]
parse = []
for j in range(stcls.c._e_i):
start = stcls.c._ents[j].start
end = stcls.c._ents[j].end
label = stcls.c._ents[j].label
parse.append((start, end, self.strings[label]))
parses.append((prob, parse))
return parses
cdef Transition lookup_transition(self, object name) except *:
cdef attr_t label
if name == '-' or name == None: