2014-12-16 11:44:43 +00:00
|
|
|
from libc.stdint cimport uint32_t
|
|
|
|
|
2014-12-02 12:48:05 +00:00
|
|
|
import numpy as np
|
|
|
|
cimport numpy as np
|
|
|
|
|
2014-10-22 14:57:59 +00:00
|
|
|
from cymem.cymem cimport Pool
|
2014-12-21 20:25:43 +00:00
|
|
|
from thinc.typedefs cimport atom_t
|
2014-10-22 14:57:59 +00:00
|
|
|
|
2014-12-21 20:25:43 +00:00
|
|
|
from .typedefs cimport flags_t
|
|
|
|
from .structs cimport Morphology, TokenC, Lexeme
|
|
|
|
from .vocab cimport Vocab
|
2014-12-19 20:03:26 +00:00
|
|
|
from .strings cimport StringStore
|
2014-12-05 04:56:14 +00:00
|
|
|
|
|
|
|
|
2014-12-09 05:50:01 +00:00
|
|
|
ctypedef const Lexeme* const_Lexeme_ptr
|
|
|
|
ctypedef TokenC* TokenC_ptr
|
|
|
|
|
|
|
|
ctypedef fused LexemeOrToken:
|
|
|
|
const_Lexeme_ptr
|
|
|
|
TokenC_ptr
|
|
|
|
|
|
|
|
|
2014-09-15 01:22:40 +00:00
|
|
|
cdef class Tokens:
|
2014-10-22 14:57:59 +00:00
|
|
|
cdef Pool mem
|
2014-12-21 20:25:43 +00:00
|
|
|
cdef Vocab vocab
|
2014-12-09 21:09:32 +00:00
|
|
|
cdef list tag_names
|
2014-10-22 14:57:59 +00:00
|
|
|
|
2014-12-05 04:56:14 +00:00
|
|
|
cdef TokenC* data
|
2014-10-22 14:57:59 +00:00
|
|
|
|
|
|
|
cdef int length
|
|
|
|
cdef int max_length
|
2014-10-14 04:21:03 +00:00
|
|
|
|
2014-12-09 05:50:01 +00:00
|
|
|
cdef int push_back(self, int i, LexemeOrToken lex_or_tok) except -1
|
2014-10-23 13:59:17 +00:00
|
|
|
|
2014-12-04 09:46:55 +00:00
|
|
|
cpdef np.ndarray[long, ndim=2] get_array(self, list features)
|
2014-12-02 12:48:05 +00:00
|
|
|
|
2014-10-23 13:59:17 +00:00
|
|
|
|
|
|
|
cdef class Token:
|
2014-12-21 20:25:43 +00:00
|
|
|
cdef readonly StringStore string_store
|
2014-10-23 13:59:17 +00:00
|
|
|
cdef public int i
|
|
|
|
cdef public int idx
|
2014-12-21 21:54:47 +00:00
|
|
|
cdef readonly int pos_id
|
|
|
|
cdef readonly int dep_id
|
2014-12-08 10:12:15 +00:00
|
|
|
cdef int lemma
|
2014-12-17 10:10:12 +00:00
|
|
|
cdef public int head
|
2014-10-23 13:59:17 +00:00
|
|
|
|
2014-12-21 20:25:43 +00:00
|
|
|
cdef public atom_t id
|
|
|
|
cdef public atom_t cluster
|
|
|
|
cdef public atom_t length
|
|
|
|
cdef public atom_t postype
|
|
|
|
cdef public atom_t sensetype
|
|
|
|
|
|
|
|
cdef public atom_t sic
|
|
|
|
cdef public atom_t norm
|
|
|
|
cdef public atom_t shape
|
|
|
|
cdef public atom_t asciied
|
|
|
|
cdef public atom_t prefix
|
|
|
|
cdef public atom_t suffix
|
2014-10-23 13:59:17 +00:00
|
|
|
|
|
|
|
cdef public float prob
|
|
|
|
|
2014-12-03 00:05:15 +00:00
|
|
|
cdef public flags_t flags
|