Fix handling of unknown tags in tagger update

This commit is contained in:
Matthew Honnibal 2018-06-25 22:00:51 +02:00
parent 69c900f003
commit 3aabf621a3
1 changed files with 3 additions and 1 deletions

View File

@ -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])