From 430473bd982a90330c0403ad8aa17b358b7060b5 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Tue, 27 Sep 2016 19:09:37 +0200 Subject: [PATCH] Raise errors when no actions are available, re Issue #429 --- spacy/syntax/parser.pyx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spacy/syntax/parser.pyx b/spacy/syntax/parser.pyx index 86f4a93f7..842a06a23 100644 --- a/spacy/syntax/parser.pyx +++ b/spacy/syntax/parser.pyx @@ -109,9 +109,11 @@ cdef class Parser: cdef int nr_class = self.moves.n_moves cdef int nr_feat = self.model.nr_feat with nogil: - self.parseC(tokens.c, tokens.length, nr_feat, nr_class) + status = self.parseC(tokens.c, tokens.length, nr_feat, nr_class) # Check for KeyboardInterrupt etc. Untested PyErr_CheckSignals() + if status != 0: + raise ValueError("Error parsing doc: %s" % tokens.text) self.moves.finalize_doc(tokens) def pipe(self, stream, int batch_size=1000, int n_threads=2):