Set rank for new vector in Vocab.set_vector (#5266)

Set `Lexeme.rank` for vectors added with `Vocab.set_vector` so that the
lexeme `ID` accessed by a model points the right row for the new vector.
This commit is contained in:
adrianeboyd 2020-04-07 12:04:51 +02:00 committed by GitHub
parent c981aa6684
commit fa760010a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -406,9 +406,9 @@ cdef class Vocab:
else:
width = self.vectors.shape[1]
self.vectors.resize((new_rows, width))
lex = self[orth] # Adds words to vocab
self.vectors.add(orth, vector=vector)
self.vectors.add(orth, vector=vector)
lex = self[orth] # Add word to vocab if necessary
row = self.vectors.add(orth, vector=vector)
lex.rank = row
def has_vector(self, orth):
"""Check whether a word has a vector. Returns False if no vectors have