mirror of
https://github.com/explosion/spaCy.git
synced 2025-07-13 09:42:26 +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:
|
else:
|
||||||
width = self.vectors.shape[1]
|
width = self.vectors.shape[1]
|
||||||
self.vectors.resize((new_rows, width))
|
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)
|
||||||
self.vectors.add(orth, vector=vector)
|
self.vectors.add(orth, vector=vector)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user