From 3aabf621a3d8bdc55789717b052c69d6ddab1225 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Mon, 25 Jun 2018 22:00:51 +0200 Subject: [PATCH] Fix handling of unknown tags in tagger update --- spacy/pipeline.pyx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spacy/pipeline.pyx b/spacy/pipeline.pyx index 477c9d6e2..7bc25c4b2 100644 --- a/spacy/pipeline.pyx +++ b/spacy/pipeline.pyx @@ -505,8 +505,10 @@ class Tagger(Pipe): for tag in gold.tags: if tag is None: correct[idx] = guesses[idx] - else: + elif tag in tag_index: correct[idx] = tag_index[tag] + else: + correct[idx] = len(tag_index)+1 idx += 1 correct = self.model.ops.xp.array(correct, dtype='i') d_scores = scores - to_categorical(correct, nb_classes=scores.shape[1])