From f3c3ce7f1ec5fec87cb5965efe1c937f4666afea Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Thu, 29 Aug 2019 21:19:54 +0200 Subject: [PATCH] Update vocab --- spacy/vocab.pyx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/spacy/vocab.pyx b/spacy/vocab.pyx index 02d5cbcff..b649fdded 100644 --- a/spacy/vocab.pyx +++ b/spacy/vocab.pyx @@ -433,6 +433,8 @@ cdef class Vocab: file_.write(self.lexemes_to_bytes()) if "vectors" not in "exclude" and self.vectors is not None: self.vectors.to_disk(path) + if "morphology" not in exclude: + self.morphology.to_disk(path / "morphology.bin") def from_disk(self, path, exclude=tuple(), **kwargs): """Loads state from a directory. Modifies the object in place and @@ -457,6 +459,8 @@ cdef class Vocab: self.vectors.from_disk(path, exclude=["strings"]) if self.vectors.name is not None: link_vectors_to_models(self) + if "morphology" not in exclude: + self.morphology.from_disk(path / "morphology.bin") return self def to_bytes(self, exclude=tuple(), **kwargs): @@ -476,7 +480,8 @@ cdef class Vocab: getters = OrderedDict(( ("strings", lambda: self.strings.to_bytes()), ("lexemes", lambda: self.lexemes_to_bytes()), - ("vectors", deserialize_vectors) + ("vectors", deserialize_vectors), + ("morphology", lambda: self.morphology.to_bytes()) )) exclude = util.get_serialization_exclude(getters, exclude, kwargs) return util.to_bytes(getters, exclude) @@ -499,7 +504,8 @@ cdef class Vocab: setters = OrderedDict(( ("strings", lambda b: self.strings.from_bytes(b)), ("lexemes", lambda b: self.lexemes_from_bytes(b)), - ("vectors", lambda b: serialize_vectors(b)) + ("vectors", lambda b: serialize_vectors(b)), + ("morphology", lambda b: self.morphology.from_bytes(b)) )) exclude = util.get_serialization_exclude(setters, exclude, kwargs) util.from_bytes(bytes_data, setters, exclude)