mirror of https://github.com/explosion/spaCy.git
Fix morphology add and update
This commit is contained in:
parent
34cab8cc49
commit
51a297f934
|
@ -23,12 +23,12 @@ cdef class Morphology:
|
||||||
cdef readonly PreshMapArray _cache
|
cdef readonly PreshMapArray _cache
|
||||||
cdef readonly int n_tags
|
cdef readonly int n_tags
|
||||||
|
|
||||||
|
cpdef update(self, hash_t morph, features)
|
||||||
cdef hash_t insert(self, RichTagC tag) except 0
|
cdef hash_t insert(self, RichTagC tag) except 0
|
||||||
|
|
||||||
cdef int assign_untagged(self, TokenC* token) 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(self, TokenC* token, tag) except -1
|
||||||
cdef int assign_tag_id(self, TokenC* token, int tag_id) except -1
|
cdef int assign_tag_id(self, TokenC* token, int tag_id) except -1
|
||||||
cpdef update_morph_key(self, hash_t morph, features)
|
|
||||||
|
|
||||||
cdef int _assign_tag_from_exceptions(self, TokenC* token, int tag_id) except -1
|
cdef int _assign_tag_from_exceptions(self, TokenC* token, int tag_id) except -1
|
||||||
|
|
||||||
|
|
|
@ -101,15 +101,14 @@ cdef class Morphology:
|
||||||
cdef hash_t key = self.insert(tag)
|
cdef hash_t key = self.insert(tag)
|
||||||
return key
|
return key
|
||||||
|
|
||||||
cpdef update_morph_key(self, hash_t morph, features):
|
cpdef update(self, hash_t morph, features):
|
||||||
"""Update a morphological analysis with new feature values."""
|
"""Update a morphological analysis with new feature values."""
|
||||||
tag = (<RichTagC*>self.tags.get(morph))[0]
|
tag = (<RichTagC*>self.tags.get(morph))[0]
|
||||||
|
features = intify_features(features)
|
||||||
cdef univ_morph_t feature
|
cdef univ_morph_t feature
|
||||||
cdef int value
|
for feature in features:
|
||||||
for feature_, value in features.items():
|
|
||||||
feature = self.strings.as_int(feature_)
|
|
||||||
set_feature(&tag, feature, 1)
|
set_feature(&tag, feature, 1)
|
||||||
morph = self.insert_tag(tag)
|
morph = self.insert(tag)
|
||||||
return morph
|
return morph
|
||||||
|
|
||||||
|
|
||||||
|
@ -237,8 +236,9 @@ cdef hash_t hash_tag(RichTagC tag) nogil:
|
||||||
cdef RichTagC create_rich_tag(features):
|
cdef RichTagC create_rich_tag(features):
|
||||||
cdef RichTagC tag
|
cdef RichTagC tag
|
||||||
cdef univ_morph_t feature
|
cdef univ_morph_t feature
|
||||||
#for feature in features:
|
memset(&tag, 0, sizeof(tag))
|
||||||
# set_feature(&tag, feature, 1)
|
for feature in features:
|
||||||
|
set_feature(&tag, feature, 1)
|
||||||
return tag
|
return tag
|
||||||
|
|
||||||
cdef tag_to_json(RichTagC tag):
|
cdef tag_to_json(RichTagC tag):
|
||||||
|
|
Loading…
Reference in New Issue