2014-12-19 20:29:16 +00:00
|
|
|
from libcpp.vector cimport vector
|
|
|
|
|
|
|
|
from preshed.maps cimport PreshMap
|
|
|
|
from cymem.cymem cimport Pool
|
|
|
|
|
|
|
|
from .typedefs cimport hash_t
|
2015-08-26 17:20:11 +00:00
|
|
|
from .structs cimport LexemeC, TokenC
|
2014-12-19 20:29:16 +00:00
|
|
|
from .strings cimport StringStore
|
2015-07-13 18:20:58 +00:00
|
|
|
from .tokens.doc cimport Doc
|
2015-08-28 00:02:33 +00:00
|
|
|
from .vocab cimport Vocab, LexemesOrTokens, _Cached
|
2014-12-19 20:29:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
cdef class Tokenizer:
|
|
|
|
cdef Pool mem
|
|
|
|
cdef PreshMap _cache
|
|
|
|
cdef PreshMap _specials
|
|
|
|
cpdef readonly Vocab vocab
|
|
|
|
|
2017-01-03 17:17:57 +00:00
|
|
|
cdef public object token_match
|
2016-09-24 18:26:17 +00:00
|
|
|
cdef public object prefix_search
|
|
|
|
cdef public object suffix_search
|
|
|
|
cdef public object infix_finditer
|
2015-10-24 05:18:47 +00:00
|
|
|
cdef object _rules
|
2014-12-19 20:29:16 +00:00
|
|
|
|
2015-07-08 16:53:00 +00:00
|
|
|
cpdef Doc tokens_from_list(self, list strings)
|
2014-12-19 20:29:16 +00:00
|
|
|
|
2015-07-13 19:46:02 +00:00
|
|
|
cdef int _try_cache(self, hash_t key, Doc tokens) except -1
|
2015-07-22 02:49:39 +00:00
|
|
|
cdef int _tokenize(self, Doc tokens, unicode span, hash_t key) except -1
|
2016-02-21 23:17:47 +00:00
|
|
|
cdef unicode _split_affixes(self, Pool mem, unicode string, vector[LexemeC*] *prefixes,
|
2015-07-22 02:49:39 +00:00
|
|
|
vector[LexemeC*] *suffixes)
|
|
|
|
cdef int _attach_tokens(self, Doc tokens, unicode string,
|
2015-01-11 23:26:22 +00:00
|
|
|
vector[LexemeC*] *prefixes, vector[LexemeC*] *suffixes) except -1
|
2015-07-22 02:49:39 +00:00
|
|
|
|
2014-12-19 20:29:16 +00:00
|
|
|
cdef int _save_cached(self, const TokenC* tokens, hash_t key, int n) except -1
|