2020-01-24 00:01:54 +03:00
|
|
|
cimport numpy as np
|
2022-07-15 12:14:08 +03:00
|
|
|
from libc.stdint cimport uint32_t, uint64_t
|
2023-06-26 12:41:03 +03:00
|
|
|
from libcpp.memory cimport shared_ptr
|
2022-07-15 12:14:08 +03:00
|
|
|
from libcpp.unordered_map cimport unordered_map
|
|
|
|
from libcpp.vector cimport vector
|
2015-08-28 03:02:33 +03:00
|
|
|
|
2015-08-27 10:16:11 +03:00
|
|
|
from .strings cimport StringStore
|
2021-04-26 17:54:23 +03:00
|
|
|
from .typedefs cimport attr_t, hash_t
|
2015-08-28 03:02:33 +03:00
|
|
|
|
2020-03-02 13:48:10 +03:00
|
|
|
|
2022-07-15 12:14:08 +03:00
|
|
|
cdef cppclass Feature:
|
|
|
|
hash_t field
|
|
|
|
hash_t value
|
|
|
|
|
|
|
|
__init__():
|
|
|
|
this.field = 0
|
|
|
|
this.value = 0
|
|
|
|
|
|
|
|
|
|
|
|
cdef cppclass MorphAnalysisC:
|
|
|
|
hash_t key
|
|
|
|
vector[Feature] features
|
|
|
|
|
|
|
|
__init__():
|
|
|
|
this.key = 0
|
|
|
|
|
2015-08-26 20:17:35 +03:00
|
|
|
cdef class Morphology:
|
2015-08-28 04:44:54 +03:00
|
|
|
cdef readonly StringStore strings
|
2022-07-15 12:14:08 +03:00
|
|
|
cdef unordered_map[hash_t, shared_ptr[MorphAnalysisC]] tags
|
2020-03-02 13:48:10 +03:00
|
|
|
|
2022-07-15 12:14:08 +03:00
|
|
|
cdef shared_ptr[MorphAnalysisC] _lookup_tag(self, hash_t tag_hash)
|
|
|
|
cdef void _intern_morph_tag(self, hash_t tag_key, feats)
|
|
|
|
cdef hash_t _add(self, features)
|
|
|
|
cdef str _normalize_features(self, features)
|
|
|
|
cdef str get_morph_str(self, hash_t morph_key)
|
|
|
|
cdef shared_ptr[MorphAnalysisC] get_morph_c(self, hash_t morph_key)
|
2019-03-07 20:33:06 +03:00
|
|
|
|
2022-07-15 12:14:08 +03:00
|
|
|
cdef int check_feature(const shared_ptr[MorphAnalysisC] morph, attr_t feature) nogil
|
|
|
|
cdef list list_features(const shared_ptr[MorphAnalysisC] morph)
|
|
|
|
cdef np.ndarray get_by_field(const shared_ptr[MorphAnalysisC] morph, attr_t field)
|
|
|
|
cdef int get_n_by_field(attr_t* results, const shared_ptr[MorphAnalysisC] morph, attr_t field) nogil
|