From 19136b0e7dc13d26fdea3119cc6e7da67a480e4b Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sat, 7 Nov 2015 05:34:37 +1100 Subject: [PATCH] * Add better debug message for illegal move --- spacy/syntax/parser.pyx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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)