mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-25 17:36:30 +03:00
d106cf66dd
Update `Morphology` to load exceptions in `Morphology.__init__` and `Morphology.load_morph_exceptions` from the format used in `MORPH_RULES` rather than the internal format with tuple keys. * Rename to `Morphology.exc` to `Morphology._exc` for internal use with tuple keys * Add `Morphology.exc` as a property that converts the internal `_exc` back to `MORPH_RULES` format, primarily for serialization
41 lines
1.4 KiB
Cython
41 lines
1.4 KiB
Cython
from cymem.cymem cimport Pool
|
|
from preshed.maps cimport PreshMap, PreshMapArray
|
|
from libc.stdint cimport uint64_t
|
|
from murmurhash cimport mrmr
|
|
cimport numpy as np
|
|
|
|
from .structs cimport TokenC, MorphAnalysisC
|
|
from .strings cimport StringStore
|
|
from .typedefs cimport hash_t, attr_t, flags_t
|
|
from .parts_of_speech cimport univ_pos_t
|
|
from . cimport symbols
|
|
|
|
|
|
cdef class Morphology:
|
|
cdef readonly Pool mem
|
|
cdef readonly StringStore strings
|
|
cdef PreshMap tags # Keyed by hash, value is pointer to tag
|
|
|
|
cdef public object lemmatizer
|
|
cdef readonly object tag_map
|
|
cdef readonly object tag_names
|
|
cdef readonly object reverse_index
|
|
cdef readonly object _exc
|
|
cdef readonly PreshMapArray _cache
|
|
cdef readonly int n_tags
|
|
|
|
cdef MorphAnalysisC create_morph_tag(self, field_feature_pairs) except *
|
|
cdef int insert(self, MorphAnalysisC tag) except -1
|
|
|
|
cdef int assign_untagged(self, TokenC* token) except -1
|
|
cdef int assign_tag(self, TokenC* token, tag) except -1
|
|
cdef int assign_tag_id(self, TokenC* token, int tag_id) except -1
|
|
|
|
cdef int _assign_tag_from_exceptions(self, TokenC* token, int tag_id) except -1
|
|
|
|
|
|
cdef int check_feature(const MorphAnalysisC* morph, attr_t feature) nogil
|
|
cdef list list_features(const MorphAnalysisC* morph)
|
|
cdef np.ndarray get_by_field(const MorphAnalysisC* morph, attr_t field)
|
|
cdef int get_n_by_field(attr_t* results, const MorphAnalysisC* morph, attr_t field) nogil
|