mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-26 01:46:28 +03:00
Add helper method to apply a transition in parser/NER
This commit is contained in:
parent
ce1fe8a510
commit
bdc77848f5
|
@ -94,6 +94,13 @@ cdef class TransitionSystem:
|
||||||
raise ValueError(Errors.E024)
|
raise ValueError(Errors.E024)
|
||||||
return history
|
return history
|
||||||
|
|
||||||
|
def apply_transition(self, StateClass state, name):
|
||||||
|
if not self.is_valid(state, name):
|
||||||
|
raise ValueError(
|
||||||
|
"Cannot apply transition {name}: invalid for the current state.".format(name=name))
|
||||||
|
action = self.lookup_transition(name)
|
||||||
|
action.do(state.c, action.label)
|
||||||
|
|
||||||
cdef int initialize_state(self, StateC* state) nogil:
|
cdef int initialize_state(self, StateC* state) nogil:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user