Fix alignment for words with spaces

This commit is contained in:
Matthew Honnibal 2018-02-25 14:55:00 +01:00
parent 9e960d24fc
commit d4fdb97c87
1 changed files with 2 additions and 0 deletions

View File

@ -66,6 +66,8 @@ def align(cand_words, gold_words):
if cand_words == gold_words:
alignment = numpy.arange(len(cand_words))
return 0, alignment, alignment, {}, {}
cand_words = [w.replace(' ', '') for w in cand_words]
gold_words = [w.replace(' ', '') for w in gold_words]
cost, i2j, j2i, matrix = _align.align(cand_words, gold_words)
i2j_multi, j2i_multi = _align.multi_align(i2j, j2i, [len(w) for w in cand_words],
[len(w) for w in gold_words])