mirror of https://github.com/explosion/spaCy.git
* Messily hook up vector in tokens
This commit is contained in:
parent
06e7456c65
commit
b65b0c07bf
|
@ -1,6 +1,6 @@
|
||||||
from libc.stdint cimport uint32_t
|
from libc.stdint cimport uint32_t
|
||||||
|
|
||||||
from cython.view cimport array as cvarray
|
from numpy cimport ndarray
|
||||||
|
|
||||||
from cymem.cymem cimport Pool
|
from cymem.cymem cimport Pool
|
||||||
from thinc.typedefs cimport atom_t
|
from thinc.typedefs cimport atom_t
|
||||||
|
@ -62,3 +62,5 @@ cdef class Token:
|
||||||
cdef readonly univ_tag_t pos
|
cdef readonly univ_tag_t pos
|
||||||
cdef readonly attr_t tag
|
cdef readonly attr_t tag
|
||||||
cdef readonly attr_t dep
|
cdef readonly attr_t dep
|
||||||
|
|
||||||
|
cdef readonly ndarray vec
|
||||||
|
|
|
@ -10,6 +10,9 @@ from .typedefs cimport LEMMA
|
||||||
from .typedefs cimport ID, SIC, NORM1, NORM2, SHAPE, PREFIX, SUFFIX, LENGTH, CLUSTER
|
from .typedefs cimport ID, SIC, NORM1, NORM2, SHAPE, PREFIX, SUFFIX, LENGTH, CLUSTER
|
||||||
from .typedefs cimport POS, LEMMA
|
from .typedefs cimport POS, LEMMA
|
||||||
|
|
||||||
|
cimport numpy
|
||||||
|
import numpy
|
||||||
|
|
||||||
cimport cython
|
cimport cython
|
||||||
|
|
||||||
|
|
||||||
|
@ -201,6 +204,10 @@ cdef class Token:
|
||||||
self.tag = t.tag
|
self.tag = t.tag
|
||||||
self.dep = t.dep
|
self.dep = t.dep
|
||||||
|
|
||||||
|
self.vec = numpy.ndarray(shape=(300,), dtype=numpy.float32)
|
||||||
|
for i in range(300):
|
||||||
|
self.vec[i] = t.lex.vec[i]
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
cdef const TokenC* t = &self._seq.data[self.i]
|
cdef const TokenC* t = &self._seq.data[self.i]
|
||||||
cdef int end_idx = t.idx + t.lex.length
|
cdef int end_idx = t.idx + t.lex.length
|
||||||
|
|
Loading…
Reference in New Issue