diff --git a/spacy/tests/regression/test_issue1807.py b/spacy/tests/regression/test_issue1807.py new file mode 100644 index 000000000..c73f008eb --- /dev/null +++ b/spacy/tests/regression/test_issue1807.py @@ -0,0 +1,14 @@ +'''Test vocab.set_vector also adds the word to the vocab.''' +from __future__ import unicode_literals +from ...vocab import Vocab + +import numpy + + +def test_issue1807(): + vocab = Vocab() + arr = numpy.ones((50,), dtype='f') + assert 'hello' not in vocab + vocab.set_vector('hello', arr) + assert 'hello' in vocab + diff --git a/spacy/vocab.pyx b/spacy/vocab.pyx index 34ad4eb67..a103bcd0e 100644 --- a/spacy/vocab.pyx +++ b/spacy/vocab.pyx @@ -335,6 +335,7 @@ cdef class Vocab: else: width = self.vectors.shape[1] self.vectors.resize((new_rows, width)) + lex = self[orth] # Adds worse to vocab self.vectors.add(orth, vector=vector) self.vectors.add(orth, vector=vector)