spaCy/spacy/lang.pxd

63 lines
1.7 KiB
Cython
Raw Normal View History

2014-08-02 20:51:52 +00:00
from libc.stdint cimport uint32_t
from libc.stdint cimport uint64_t
2014-08-25 14:42:22 +00:00
from spacy.word cimport Lexeme
2014-09-10 16:11:13 +00:00
from spacy.tokens cimport Tokens
from spacy.lexeme cimport LexemeC
from preshed.maps cimport PreshMap
2014-09-10 16:11:13 +00:00
from cymem.cymem cimport Pool
from libcpp.utility cimport pair
from libcpp.vector cimport vector
from libc.stdint cimport uint64_t, int64_t
2014-09-10 16:11:13 +00:00
cdef extern from "Python.h":
cdef bint Py_UNICODE_ISSPACE(Py_UNICODE ch)
cdef bint Py_UNICODE_ISALNUM(Py_UNICODE ch)
cdef struct String:
Py_UNICODE* chars
size_t n
uint64_t key
cdef class Lexicon:
cdef Pool _mem
2014-09-10 16:11:13 +00:00
cpdef readonly size_t size
cpdef Lexeme lookup(self, unicode string)
cdef LexemeC* get(self, String* s) except NULL
2014-08-28 23:59:23 +00:00
cdef PreshMap _dict
2014-08-28 23:59:23 +00:00
cdef list _string_features
cdef list _flag_features
cdef class Language:
cdef Pool _mem
2014-08-28 23:59:23 +00:00
cdef unicode name
cdef PreshMap cache
cdef PreshMap specials
cpdef readonly Lexicon lexicon
cdef object prefix_re
cdef object suffix_re
2014-09-11 19:37:32 +00:00
cpdef Tokens tokenize(self, unicode text)
2014-08-28 23:59:23 +00:00
cpdef Lexeme lookup(self, unicode text)
2014-08-16 01:22:03 +00:00
cdef int _check_cache(self, vector[LexemeC*] *tokens, String* string) except -1
cdef int _tokenize(self, vector[LexemeC*] *tokens_v, String* string) except -1
cdef int _find_prefix(self, Py_UNICODE* characters, size_t length)
cdef int _find_suffix(self, Py_UNICODE* characters, size_t length)
cdef int _attach_tokens(self, vector[LexemeC*] *tokens, String* string,
vector[LexemeC*] *prefixes,
vector[LexemeC*] *suffixes) except -1
cdef int _save_cached(self, vector[LexemeC*] *tokens, uint64_t key, size_t n) except -1