diff --git a/spacy/syntax/parser.pyx b/spacy/syntax/parser.pyx index f746dd715..6d31291e3 100644 --- a/spacy/syntax/parser.pyx +++ b/spacy/syntax/parser.pyx @@ -105,9 +105,12 @@ cdef class Parser: self.moves.set_valid(eg.is_valid, stcls) self.model.set_prediction(&eg) - assert eg.is_valid[eg.guess] - action = self.moves.c[eg.guess] + if not eg.is_valid[eg.guess]: + raise ValueError( + "Illegal action: %s" % self.moves.move_name(action.move, action.label) + ) + action.do(stcls, action.label) self.moves.finalize_state(stcls) tokens.set_parse(stcls._sent)