2014-10-14 04:47:06 +00:00
|
|
|
from libcpp.vector cimport vector
|
2014-09-10 16:11:13 +00:00
|
|
|
|
2014-12-02 12:46:59 +00:00
|
|
|
from cpython cimport Py_UNICODE_ISSPACE, Py_UNICODE_ISALPHA, Py_UNICODE_ISUPPER
|
|
|
|
|
2014-10-14 04:47:06 +00:00
|
|
|
from preshed.maps cimport PreshMap
|
2014-09-17 21:09:24 +00:00
|
|
|
from cymem.cymem cimport Pool
|
2014-09-17 18:02:26 +00:00
|
|
|
|
2014-10-23 13:59:17 +00:00
|
|
|
from .typedefs cimport hash_t
|
2014-10-14 04:47:06 +00:00
|
|
|
from .tokens cimport Tokens
|
2014-10-23 13:59:17 +00:00
|
|
|
from .lexeme cimport Lexeme
|
2014-12-03 00:04:00 +00:00
|
|
|
from .utf8string cimport StringStore, UniStr
|
2014-09-12 21:50:37 +00:00
|
|
|
|
|
|
|
|
2014-08-27 15:15:39 +00:00
|
|
|
cdef class Lexicon:
|
2014-12-03 00:04:00 +00:00
|
|
|
cpdef public set_flags
|
2014-10-14 04:47:06 +00:00
|
|
|
cdef Pool mem
|
2014-09-10 16:11:13 +00:00
|
|
|
cpdef readonly size_t size
|
2014-10-23 13:59:17 +00:00
|
|
|
cpdef readonly StringStore strings
|
2014-10-31 06:43:25 +00:00
|
|
|
cdef vector[Lexeme*] lexemes
|
2014-09-10 16:11:13 +00:00
|
|
|
|
2014-12-03 04:44:25 +00:00
|
|
|
cdef const Lexeme* get(self, UniStr* s) except NULL
|
2014-08-28 23:59:23 +00:00
|
|
|
|
2014-12-02 12:46:59 +00:00
|
|
|
cdef PreshMap _map
|
2014-08-28 23:59:23 +00:00
|
|
|
|
2014-10-23 13:59:17 +00:00
|
|
|
|
2014-07-07 10:47:21 +00:00
|
|
|
cdef class Language:
|
2014-10-30 07:01:27 +00:00
|
|
|
cdef Pool mem
|
|
|
|
cdef readonly unicode name
|
|
|
|
cdef PreshMap _cache
|
|
|
|
cdef PreshMap _specials
|
2014-08-27 15:15:39 +00:00
|
|
|
cpdef readonly Lexicon lexicon
|
2014-07-07 02:21:06 +00:00
|
|
|
|
2014-10-30 07:01:27 +00:00
|
|
|
cdef object _prefix_re
|
|
|
|
cdef object _suffix_re
|
|
|
|
cdef object _infix_re
|
2014-09-25 16:22:52 +00:00
|
|
|
|
2014-11-11 12:43:14 +00:00
|
|
|
cpdef Tokens tokens_from_list(self, list strings)
|
2014-09-11 19:37:32 +00:00
|
|
|
cpdef Tokens tokenize(self, unicode text)
|
2014-09-16 11:16:02 +00:00
|
|
|
|
2014-12-03 00:04:00 +00:00
|
|
|
cdef int _tokenize(self, Tokens tokens, UniStr* span, int start, int end) except -1
|
|
|
|
cdef UniStr* _split_affixes(self, UniStr* string, vector[Lexeme*] *prefixes,
|
2014-10-23 13:59:17 +00:00
|
|
|
vector[Lexeme*] *suffixes) except NULL
|
2014-12-03 00:04:00 +00:00
|
|
|
cdef int _attach_tokens(self, Tokens tokens, int idx, UniStr* string,
|
2014-10-23 13:59:17 +00:00
|
|
|
vector[Lexeme*] *prefixes, vector[Lexeme*] *suffixes) except -1
|
2014-10-14 04:47:06 +00:00
|
|
|
cdef int _find_prefix(self, Py_UNICODE* characters, size_t length) except -1
|
|
|
|
cdef int _find_suffix(self, Py_UNICODE* characters, size_t length) except -1
|
|
|
|
cdef int _find_infix(self, Py_UNICODE* characters, size_t length) except -1
|
2014-12-03 04:44:25 +00:00
|
|
|
cdef int _save_cached(self, const Lexeme* const* tokens, hash_t key, int n) except -1
|
2014-09-16 11:16:02 +00:00
|
|
|
|