mirror of
https://github.com/explosion/spaCy.git
synced 2025-08-06 05:10:21 +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
|
||||
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue
Block a user