Fix bug in multi-task objective

This commit is contained in:
Matthew Honnibal 2018-02-23 23:48:09 +01:00
parent 2c9c8b8d72
commit 968dabdde4
1 changed files with 3 additions and 7 deletions

View File

@ -690,11 +690,7 @@ class MultitaskObjective(Tagger):
for i, gold in enumerate(golds):
for j in range(len(docs[i])):
# Handes alignment for tokenization differences
gold_idx = gold.cand_to_gold[j]
if gold_idx is None:
idx += 1
continue
label = self.make_label(gold_idx, gold.words, gold.tags,
label = self.make_label(j, gold.words, gold.tags,
gold.heads, gold.labels, gold.ents)
if label is None or label not in self.labels:
correct[idx] = guesses[idx]
@ -749,6 +745,8 @@ class MultitaskObjective(Tagger):
of gold data. You can pass cache=False if you know the cache will
do the wrong thing.
'''
assert len(words) == len(heads)
assert target < len(words), (target, len(words))
if cache:
if id(heads) in _cache:
return _cache[id(heads)][target]
@ -783,8 +781,6 @@ class MultitaskObjective(Tagger):
return sent_tags[target]
class SimilarityHook(Pipe):
"""
Experimental: A pipeline component to install a hook for supervised