mirror of https://github.com/explosion/spaCy.git
Fix sent_start multi-task objective when alignment fails
This commit is contained in:
parent
5fa44e93f1
commit
4492a33a9d
|
@ -761,19 +761,18 @@ class MultitaskObjective(Tagger):
|
|||
sent_tags = ['I-SENT'] * len(words)
|
||||
|
||||
def _find_root(child):
|
||||
while heads[child] != child:
|
||||
if heads[child] is None:
|
||||
if child == 0:
|
||||
return child
|
||||
else:
|
||||
child -= 1
|
||||
else:
|
||||
seen = set([child])
|
||||
while child is not None and heads[child] != child:
|
||||
seen.add(child)
|
||||
child = heads[child]
|
||||
return child
|
||||
|
||||
sentences = {}
|
||||
for i in range(len(words)):
|
||||
root = _find_root(i)
|
||||
if root is None:
|
||||
sent_tags[i] = None
|
||||
else:
|
||||
sentences.setdefault(root, []).append(i)
|
||||
for root, span in sorted(sentences.items()):
|
||||
if len(span) == 1:
|
||||
|
|
Loading…
Reference in New Issue