* Messily hook up vector in tokens

This commit is contained in:
Matthew Honnibal 2015-01-19 19:59:55 +11:00
parent 06e7456c65
commit b65b0c07bf
2 changed files with 10 additions and 1 deletions

View File

@ -1,6 +1,6 @@
from libc.stdint cimport uint32_t
from cython.view cimport array as cvarray
from numpy cimport ndarray
from cymem.cymem cimport Pool
from thinc.typedefs cimport atom_t
@ -62,3 +62,5 @@ cdef class Token:
cdef readonly univ_tag_t pos
cdef readonly attr_t tag
cdef readonly attr_t dep
cdef readonly ndarray vec

View File

@ -10,6 +10,9 @@ from .typedefs cimport LEMMA
from .typedefs cimport ID, SIC, NORM1, NORM2, SHAPE, PREFIX, SUFFIX, LENGTH, CLUSTER
from .typedefs cimport POS, LEMMA
cimport numpy
import numpy
cimport cython
@ -201,6 +204,10 @@ cdef class Token:
self.tag = t.tag
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):
cdef const TokenC* t = &self._seq.data[self.i]
cdef int end_idx = t.idx + t.lex.length