From 5b89e2454c0386eba8f0a7e1e6fff901dee45dbd Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Thu, 27 Aug 2015 10:26:36 +0200 Subject: [PATCH] * Improve error-reporting in tagger --- spacy/tagger.pyx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spacy/tagger.pyx b/spacy/tagger.pyx index 7b638c724..dff96e6ea 100644 --- a/spacy/tagger.pyx +++ b/spacy/tagger.pyx @@ -159,7 +159,11 @@ cdef class Tagger: cdef int i cdef int loss cdef const weight_t* scores - golds = [self.tag_names.index(g) if g is not None else -1 for g in gold_tag_strs] + try: + golds = [self.tag_names.index(g) if g is not None else -1 for g in gold_tag_strs] + except ValueError: + raise ValueError( + [g for g in gold_tag_strs if g is not None and g not in self.tag_names]) correct = 0 for i in range(tokens.length): guess = self.update(i, tokens.data, golds[i])