mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-26 01:46:28 +03:00
Make set_vector add word to vocab. Fixes #1807
This commit is contained in:
parent
55754f0cee
commit
0153220304
14
spacy/tests/regression/test_issue1807.py
Normal file
14
spacy/tests/regression/test_issue1807.py
Normal file
|
@ -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
|
||||
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user