From bdc77848f5eb9ada0f900ec07b471b6a6b72e30a Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sun, 10 Mar 2019 13:00:00 +0100 Subject: [PATCH] Add helper method to apply a transition in parser/NER --- spacy/syntax/transition_system.pyx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/spacy/syntax/transition_system.pyx b/spacy/syntax/transition_system.pyx index 5ec254e04..4cc00828e 100644 --- a/spacy/syntax/transition_system.pyx +++ b/spacy/syntax/transition_system.pyx @@ -94,6 +94,13 @@ cdef class TransitionSystem: raise ValueError(Errors.E024) 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: pass