Skip to content

Commit

Permalink
Fix Issue #429. Add an initialize_state method to the named entity re…
Browse files Browse the repository at this point in the history
…cogniser that adds missing entity types. This is a messy place to add this, because it's strange to have the method mutate state. A better home for this logic could be found.
  • Loading branch information
honnibal committed Oct 27, 2016
1 parent afea650 commit 301f3cc
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions spacy/syntax/ner.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,15 @@ cdef class BiluoPushDown(TransitionSystem):
raise Exception(move)
return t

cdef int initialize_state(self, StateC* st) nogil:
for i in range(st.length):
if st._sent[i].ent_type != 0:
with gil:
self.add_action(BEGIN, st._sent[i].ent_type)
self.add_action(IN, st._sent[i].ent_type)
self.add_action(UNIT, st._sent[i].ent_type)
self.add_action(LAST, st._sent[i].ent_type)


cdef class Missing:
@staticmethod
Expand Down

0 comments on commit 301f3cc

Please sign in to comment.