From f204daf27b9e96aacb64abe964a99298a798afc4 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Tue, 2 Feb 2016 22:59:59 +0100 Subject: [PATCH] * Add error warning that a gold tag is unrecognised --- spacy/tagger.pyx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spacy/tagger.pyx b/spacy/tagger.pyx index 493cc4f99..97ec0eff6 100644 --- a/spacy/tagger.pyx +++ b/spacy/tagger.pyx @@ -216,6 +216,11 @@ cdef class Tagger: def train(self, Doc tokens, object gold_tag_strs): assert len(tokens) == len(gold_tag_strs) + for tag in gold_tag_strs: + if tag not in self.tag_names: + msg = ("Unrecognized gold tag: %s. tag_map.json must contain all" + "gold tags, to maintain coarse-grained mapping.") + raise ValueError(msg % tag) golds = [self.tag_names.index(g) if g is not None else -1 for g in gold_tag_strs] cdef int correct = 0 cdef Pool mem = Pool()