2014-12-19 23:29:16 +03:00
|
|
|
from libcpp.vector cimport vector
|
|
|
|
|
|
|
|
from preshed.maps cimport PreshMap
|
|
|
|
from cymem.cymem cimport Pool
|
|
|
|
|
|
|
|
from .typedefs cimport hash_t
|
2015-08-26 20:20:11 +03:00
|
|
|
from .structs cimport LexemeC, TokenC
|
2014-12-19 23:29:16 +03:00
|
|
|
from .strings cimport StringStore
|
2015-07-13 21:20:58 +03:00
|
|
|
from .tokens.doc cimport Doc
|
2015-08-28 03:02:33 +03:00
|
|
|
from .vocab cimport Vocab, LexemesOrTokens, _Cached
|
2014-12-19 23:29:16 +03:00
|
|
|
|
|
|
|
|
|
|
|
cdef class Tokenizer:
|
|
|
|
cdef Pool mem
|
|
|
|
cdef PreshMap _cache
|
|
|
|
cdef PreshMap _specials
|
|
|
|
cpdef readonly Vocab vocab
|
|
|
|
|
2019-09-08 21:52:46 +03:00
|
|
|
cdef object _token_match
|
|
|
|
cdef object _prefix_search
|
|
|
|
cdef object _suffix_search
|
|
|
|
cdef object _infix_finditer
|
2015-10-24 08:18:47 +03:00
|
|
|
cdef object _rules
|
2019-09-08 21:29:59 +03:00
|
|
|
cdef object _special_matcher
|
2019-09-08 23:40:08 +03:00
|
|
|
cdef int _property_init_count
|
2014-12-19 23:29:16 +03:00
|
|
|
|
2015-07-08 19:53:00 +03:00
|
|
|
cpdef Doc tokens_from_list(self, list strings)
|
2014-12-19 23:29:16 +03:00
|
|
|
|
2019-09-16 15:16:30 +03:00
|
|
|
cdef Doc _tokenize_affixes(self, unicode string, bint with_special_cases)
|
2019-09-08 21:29:59 +03:00
|
|
|
cdef int _apply_special_cases(self, Doc doc)
|
2015-07-13 22:46:02 +03:00
|
|
|
cdef int _try_cache(self, hash_t key, Doc tokens) except -1
|
2019-09-16 15:16:30 +03:00
|
|
|
cdef int _try_specials(self, hash_t key, Doc tokens,
|
|
|
|
int* has_special) except -1
|
|
|
|
cdef int _tokenize(self, Doc tokens, unicode span, hash_t key,
|
|
|
|
int* has_special, bint with_special_cases) except -1
|
|
|
|
cdef unicode _split_affixes(self, Pool mem, unicode string,
|
|
|
|
vector[LexemeC*] *prefixes,
|
|
|
|
vector[LexemeC*] *suffixes, int* has_special,
|
|
|
|
bint with_special_cases)
|
2015-07-22 05:49:39 +03:00
|
|
|
cdef int _attach_tokens(self, Doc tokens, unicode string,
|
2019-09-16 15:16:30 +03:00
|
|
|
vector[LexemeC*] *prefixes,
|
|
|
|
vector[LexemeC*] *suffixes, int* has_special,
|
|
|
|
bint with_special_cases) except -1
|
2019-09-08 21:29:59 +03:00
|
|
|
cdef int _save_cached(self, const TokenC* tokens, hash_t key,
|
2019-09-16 15:16:30 +03:00
|
|
|
int* has_special, int n) except -1
|