From 9e83513004ed1c9509389208aaa611360d46e266 Mon Sep 17 00:00:00 2001 From: ines Date: Tue, 27 Mar 2018 23:56:59 +0200 Subject: [PATCH] Add position of invalid token to error message --- spacy/tokens/doc.pyx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spacy/tokens/doc.pyx b/spacy/tokens/doc.pyx index 4bb1db46f..8c5e04ea6 100644 --- a/spacy/tokens/doc.pyx +++ b/spacy/tokens/doc.pyx @@ -558,7 +558,8 @@ cdef class Doc: t.l_edge = self.length t.r_edge = self.length if t.lex.orth == 0: - raise ValueError("Invalid token: empty string ('')") + raise ValueError("Invalid token: empty string ('') at position {}" + .format(self.length)) t.spacy = has_space self.length += 1 return t.idx + t.lex.length + t.spacy