Skip vector ngram backoff if minn is not set (#7925)

This commit is contained in:
Adriane Boyd 2021-05-06 10:34:35 +02:00 committed by GitHub
parent e9037d8fc0
commit 7d5db41ac3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -364,15 +364,15 @@ cdef class Vocab:
word = self[orth].orth_
if orth in self.vectors.key2row:
return self.vectors[orth]
# Assign default ngram limits to minn and maxn which is the length of the word.
if minn is None:
minn = len(word)
if maxn is None:
maxn = len(word)
xp = get_array_module(self.vectors.data)
vectors = xp.zeros((self.vectors_length,), dtype="f")
if minn is None:
return vectors
# Fasttext's ngram computation taken from
# https://github.com/facebookresearch/fastText
# Assign default ngram limit to maxn which is the length of the word.
if maxn is None:
maxn = len(word)
ngrams_size = 0;
for i in range(len(word)):
ngram = ""