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:
shademe 2022-11-18 14:47:15 +01:00
parent d0fc871a1c
commit d69113f4ca
No known key found for this signature in database
GPG Key ID: 6FCA9FC635B2A402

View File

@ -27,9 +27,7 @@ cdef class Morphology:
self.strings = strings
def __reduce__(self):
tags = set([self.get(self.strings[s]) for s in self.strings])
tags -= set([""])
return (unpickle_morphology, (self.strings, sorted(tags)), None, None)
return (unpickle_morphology, (self.strings,), None, None)
cdef shared_ptr[MorphAnalysisC] _lookup_tag(self, hash_t 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
return n_results
def unpickle_morphology(strings, tags):
def unpickle_morphology(strings):
cdef Morphology morphology = Morphology(strings)
for tag in tags:
morphology.add(tag)
# Repopulate the tag map.
for string in strings:
morphology.add(string)
return morphology