mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-27 09:44:36 +03:00
* Support setting of word vectors on Lexeme object.
This commit is contained in:
parent
27f988b167
commit
dd4d64b235
|
@ -54,10 +54,16 @@ cdef class Lexeme:
|
||||||
|
|
||||||
property vector:
|
property vector:
|
||||||
def __get__(self):
|
def __get__(self):
|
||||||
cdef int length = self.vocab.repvec_length
|
cdef int length = self.vocab.vector_length
|
||||||
repvec_view = <float[:length,]>self.c.repvec
|
repvec_view = <float[:length,]>self.c.repvec
|
||||||
return numpy.asarray(repvec_view)
|
return numpy.asarray(repvec_view)
|
||||||
|
|
||||||
|
def __set__(self, vector):
|
||||||
|
assert len(vector) == self.vocab.vector_length
|
||||||
|
cdef float value
|
||||||
|
for i, value in enumerate(vector):
|
||||||
|
self.c.repvec[i] = value
|
||||||
|
|
||||||
property repvec:
|
property repvec:
|
||||||
def __get__(self):
|
def __get__(self):
|
||||||
return self.vector
|
return self.vector
|
||||||
|
|
Loading…
Reference in New Issue
Block a user