mirror of
https://github.com/explosion/spaCy.git
synced 2025-08-07 13:44:55 +03:00
Morphology
: Don't pickle tags
member variable
The information required to recreate the `tags` map is present in the string store, so it's not necessary to serialize it as well.
This commit is contained in:
parent
d0fc871a1c
commit
d69113f4ca
|
@ -27,9 +27,7 @@ cdef class Morphology:
|
||||||
self.strings = strings
|
self.strings = strings
|
||||||
|
|
||||||
def __reduce__(self):
|
def __reduce__(self):
|
||||||
tags = set([self.get(self.strings[s]) for s in self.strings])
|
return (unpickle_morphology, (self.strings,), None, None)
|
||||||
tags -= set([""])
|
|
||||||
return (unpickle_morphology, (self.strings, sorted(tags)), None, None)
|
|
||||||
|
|
||||||
cdef shared_ptr[MorphAnalysisC] _lookup_tag(self, hash_t tag_hash):
|
cdef shared_ptr[MorphAnalysisC] _lookup_tag(self, hash_t tag_hash):
|
||||||
match = self.tags.find(tag_hash)
|
match = self.tags.find(tag_hash)
|
||||||
|
@ -244,8 +242,9 @@ cdef int get_n_by_field(attr_t* results, const shared_ptr[MorphAnalysisC] morph,
|
||||||
n_results += 1
|
n_results += 1
|
||||||
return n_results
|
return n_results
|
||||||
|
|
||||||
def unpickle_morphology(strings, tags):
|
def unpickle_morphology(strings):
|
||||||
cdef Morphology morphology = Morphology(strings)
|
cdef Morphology morphology = Morphology(strings)
|
||||||
for tag in tags:
|
# Repopulate the tag map.
|
||||||
morphology.add(tag)
|
for string in strings:
|
||||||
|
morphology.add(string)
|
||||||
return morphology
|
return morphology
|
||||||
|
|
Loading…
Reference in New Issue
Block a user