mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-25 01:16:28 +03:00
Fix tag set serialisation
This commit is contained in:
parent
2a061e2777
commit
9bf22a94aa
|
@ -292,10 +292,11 @@ cdef class Vocab:
|
|||
**exclude: Named attributes to prevent from being serialized.
|
||||
RETURNS (bytes): The serialized form of the `Vocab` object.
|
||||
"""
|
||||
getters = {
|
||||
'strings': lambda: self.strings.to_bytes(),
|
||||
'lexemes': lambda: self.lexemes_to_bytes()
|
||||
}
|
||||
getters = OrderedDict((
|
||||
('strings', lambda: self.strings.to_bytes()),
|
||||
('lexemes', lambda: self.lexemes_to_bytes()),
|
||||
('tag_map', lambda: self.morphology.tag_map),
|
||||
))
|
||||
return util.to_bytes(getters, exclude)
|
||||
|
||||
def from_bytes(self, bytes_data, **exclude):
|
||||
|
@ -305,9 +306,13 @@ cdef class Vocab:
|
|||
**exclude: Named attributes to prevent from being loaded.
|
||||
RETURNS (Vocab): The `Vocab` object.
|
||||
"""
|
||||
def set_tag_map(tag_map):
|
||||
self.morphology = Morphology(self.strings, tag_map,
|
||||
self.morphology.lemmatizer)
|
||||
setters = OrderedDict((
|
||||
('strings', lambda b: self.strings.from_bytes(b)),
|
||||
('lexemes', lambda b: self.lexemes_from_bytes(b))
|
||||
('lexemes', lambda b: self.lexemes_from_bytes(b)),
|
||||
('tag_map', lambda b: set_tag_map(b))
|
||||
))
|
||||
return util.from_bytes(bytes_data, setters, exclude)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user