From 693971dd8fda2ffcce5c28d9d14381cae5d85780 Mon Sep 17 00:00:00 2001 From: ines Date: Tue, 27 Mar 2018 22:25:40 +0200 Subject: [PATCH] Improve error message if token text is empty string (see #2101) --- 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 07f1f3336..4bb1db46f 100644 --- a/spacy/tokens/doc.pyx +++ b/spacy/tokens/doc.pyx @@ -557,7 +557,8 @@ cdef class Doc: t.idx = (t-1).idx + (t-1).lex.length + (t-1).spacy t.l_edge = self.length t.r_edge = self.length - assert t.lex.orth != 0 + if t.lex.orth == 0: + raise ValueError("Invalid token: empty string ('')") t.spacy = has_space self.length += 1 return t.idx + t.lex.length + t.spacy