mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-26 01:46: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.
|
**exclude: Named attributes to prevent from being serialized.
|
||||||
RETURNS (bytes): The serialized form of the `Vocab` object.
|
RETURNS (bytes): The serialized form of the `Vocab` object.
|
||||||
"""
|
"""
|
||||||
getters = {
|
getters = OrderedDict((
|
||||||
'strings': lambda: self.strings.to_bytes(),
|
('strings', lambda: self.strings.to_bytes()),
|
||||||
'lexemes': lambda: self.lexemes_to_bytes()
|
('lexemes', lambda: self.lexemes_to_bytes()),
|
||||||
}
|
('tag_map', lambda: self.morphology.tag_map),
|
||||||
|
))
|
||||||
return util.to_bytes(getters, exclude)
|
return util.to_bytes(getters, exclude)
|
||||||
|
|
||||||
def from_bytes(self, bytes_data, **exclude):
|
def from_bytes(self, bytes_data, **exclude):
|
||||||
|
@ -305,9 +306,13 @@ cdef class Vocab:
|
||||||
**exclude: Named attributes to prevent from being loaded.
|
**exclude: Named attributes to prevent from being loaded.
|
||||||
RETURNS (Vocab): The `Vocab` object.
|
RETURNS (Vocab): The `Vocab` object.
|
||||||
"""
|
"""
|
||||||
|
def set_tag_map(tag_map):
|
||||||
|
self.morphology = Morphology(self.strings, tag_map,
|
||||||
|
self.morphology.lemmatizer)
|
||||||
setters = OrderedDict((
|
setters = OrderedDict((
|
||||||
('strings', lambda b: self.strings.from_bytes(b)),
|
('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)
|
return util.from_bytes(bytes_data, setters, exclude)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user