mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-12 18:26:30 +03:00
Auto-add words to vocab when loading vectors
When calling vocab.load_vectors_from_bin_loc, ensure that missing entries are added to the vocab. Otherwise, loading vectors into an empty vocab object resulted in no vectors being added.
This commit is contained in:
parent
271997a146
commit
4bfc55b532
|
@ -533,6 +533,8 @@ cdef class Vocab:
|
|||
vec = <float*>file_.alloc_read(self.mem, vec_len, sizeof(float))
|
||||
|
||||
string_id = self.strings[chars[:word_len]]
|
||||
# Insert words into vocab to add vector.
|
||||
self.get_by_orth(self.mem, string_id)
|
||||
while string_id >= vectors.size():
|
||||
vectors.push_back(EMPTY_VEC)
|
||||
assert vec != NULL
|
||||
|
|
Loading…
Reference in New Issue
Block a user