2014-12-16 14:44:43 +03:00
|
|
|
from libc.stdint cimport uint32_t
|
|
|
|
|
2014-12-02 15:48:05 +03:00
|
|
|
import numpy as np
|
|
|
|
cimport numpy as np
|
|
|
|
|
2014-10-22 18:57:59 +04:00
|
|
|
from cymem.cymem cimport Pool
|
2014-12-21 23:25:43 +03:00
|
|
|
from thinc.typedefs cimport atom_t
|
2014-10-22 18:57:59 +04:00
|
|
|
|
2014-12-24 09:42:00 +03:00
|
|
|
from .typedefs cimport flags_t, attr_id_t, attr_t
|
2014-12-21 23:25:43 +03:00
|
|
|
from .structs cimport Morphology, TokenC, Lexeme
|
|
|
|
from .vocab cimport Vocab
|
2014-12-19 23:03:26 +03:00
|
|
|
from .strings cimport StringStore
|
2014-12-05 07:56:14 +03:00
|
|
|
|
|
|
|
|
2014-12-09 08:50:01 +03:00
|
|
|
ctypedef const Lexeme* const_Lexeme_ptr
|
|
|
|
ctypedef TokenC* TokenC_ptr
|
|
|
|
|
|
|
|
ctypedef fused LexemeOrToken:
|
|
|
|
const_Lexeme_ptr
|
|
|
|
TokenC_ptr
|
|
|
|
|
|
|
|
|
2014-12-24 09:42:00 +03:00
|
|
|
cdef attr_t get_lex_attr(const Lexeme* lex, attr_id_t feat_name) nogil
|
|
|
|
cdef attr_t get_token_attr(const TokenC* lex, attr_id_t feat_name) nogil
|
|
|
|
|
|
|
|
cdef inline bint check_flag(const Lexeme* lexeme, attr_id_t flag_id) nogil:
|
|
|
|
return lexeme.flags & (1 << flag_id)
|
|
|
|
|
|
|
|
|
2014-09-15 05:22:40 +04:00
|
|
|
cdef class Tokens:
|
2014-10-22 18:57:59 +04:00
|
|
|
cdef Pool mem
|
2014-12-21 23:25:43 +03:00
|
|
|
cdef Vocab vocab
|
2014-12-10 00:09:32 +03:00
|
|
|
cdef list tag_names
|
2014-10-22 18:57:59 +04:00
|
|
|
|
2014-12-05 07:56:14 +03:00
|
|
|
cdef TokenC* data
|
2014-10-22 18:57:59 +04:00
|
|
|
|
|
|
|
cdef int length
|
|
|
|
cdef int max_length
|
2014-10-14 08:21:03 +04:00
|
|
|
|
2014-12-09 08:50:01 +03:00
|
|
|
cdef int push_back(self, int i, LexemeOrToken lex_or_tok) except -1
|
2014-10-23 17:59:17 +04:00
|
|
|
|
2014-12-23 07:18:48 +03:00
|
|
|
cpdef np.ndarray[long, ndim=2] to_array(self, object features)
|
2014-12-02 15:48:05 +03:00
|
|
|
|
2014-10-23 17:59:17 +04:00
|
|
|
|
|
|
|
cdef class Token:
|
2014-12-24 09:42:00 +03:00
|
|
|
cdef Tokens _seq
|
|
|
|
cdef readonly int i
|