From d67b0f196a2fc09479099a52d64462527c83a647 Mon Sep 17 00:00:00 2001 From: adrianeboyd Date: Wed, 13 Nov 2019 21:22:18 +0100 Subject: [PATCH] Fix initialization of token mappings in new align (#4640) Initialize all values in `a2b` and `b2a` since `numpy.empty()` otherwise result unspecified integers. --- spacy/gold.pyx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spacy/gold.pyx b/spacy/gold.pyx index ea3589ea5..d79bc8205 100644 --- a/spacy/gold.pyx +++ b/spacy/gold.pyx @@ -129,6 +129,8 @@ def align(tokens_a, tokens_b): cost = 0 a2b = numpy.empty(len(tokens_a), dtype="i") b2a = numpy.empty(len(tokens_b), dtype="i") + a2b.fill(-1) + b2a.fill(-1) a2b_multi = {} b2a_multi = {} i = 0 @@ -138,7 +140,6 @@ def align(tokens_a, tokens_b): while i < len(tokens_a) and j < len(tokens_b): a = tokens_a[i][offset_a:] b = tokens_b[j][offset_b:] - a2b[i] = b2a[j] = -1 if a == b: if offset_a == offset_b == 0: a2b[i] = j