From 4f82a02b70664a660736d629d5571122766fe5c6 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Tue, 25 Aug 2020 14:37:45 +0200 Subject: [PATCH] Remove 'fix_pretrained_vectors_name' hack --- spacy/language.py | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/spacy/language.py b/spacy/language.py index ee238ed42..bac90af85 100644 --- a/spacy/language.py +++ b/spacy/language.py @@ -1538,7 +1538,6 @@ class Language: def deserialize_vocab(path: Path) -> None: if path.exists(): self.vocab.from_disk(path) - _fix_pretrained_vectors_name(self) path = util.ensure_path(path) deserializers = {} @@ -1605,14 +1604,10 @@ class Language: # from self.vocab.vectors, so set the name directly self.vocab.vectors.name = data.get("vectors", {}).get("name") - def deserialize_vocab(b): - self.vocab.from_bytes(b) - _fix_pretrained_vectors_name(self) - deserializers = {} deserializers["config.cfg"] = lambda b: self.config.from_bytes(b) deserializers["meta.json"] = deserialize_meta - deserializers["vocab"] = deserialize_vocab + deserializers["vocab"] = self.vocab.from_bytes deserializers["tokenizer"] = lambda b: self.tokenizer.from_bytes( b, exclude=["vocab"] ) @@ -1646,25 +1641,6 @@ class FactoryMeta: default_score_weights: Optional[Dict[str, float]] = None # noqa: E704 -def _fix_pretrained_vectors_name(nlp: Language) -> None: - # TODO: Replace this once we handle vectors consistently as static - # data - if "vectors" in nlp.meta and "name" in nlp.meta["vectors"]: - nlp.vocab.vectors.name = nlp.meta["vectors"]["name"] - elif not nlp.vocab.vectors.size: - nlp.vocab.vectors.name = None - elif "name" in nlp.meta and "lang" in nlp.meta: - vectors_name = f"{nlp.meta['lang']}_{nlp.meta['name']}.vectors" - nlp.vocab.vectors.name = vectors_name - else: - raise ValueError(Errors.E092) - for name, proc in nlp.pipeline: - if not hasattr(proc, "cfg") or not isinstance(proc.cfg, dict): - continue - proc.cfg.setdefault("deprecation_fixes", {}) - proc.cfg["deprecation_fixes"]["vectors_name"] = nlp.vocab.vectors.name - - class DisabledPipes(list): """Manager for temporary pipeline disabling."""