From 307ffe472d484d48dc2fac36481eb21b059b25d5 Mon Sep 17 00:00:00 2001 From: Ines Montani Date: Sat, 27 Jul 2019 13:17:43 +0200 Subject: [PATCH] Support custom language factory setting in meta.json (#4031) --- spacy/util.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/spacy/util.py b/spacy/util.py index 1a40bb5ca..713501924 100644 --- a/spacy/util.py +++ b/spacy/util.py @@ -160,7 +160,10 @@ def load_model_from_path(model_path, meta=False, **overrides): pipeline from meta.json and then calls from_disk() with path.""" if not meta: meta = get_model_meta(model_path) - cls = get_lang_class(meta["lang"]) + # Support language factories registered via entry points (e.g. custom + # language subclass) while keeping top-level language identifier "lang" + lang = meta.get("lang_factory", meta["lang"]) + cls = get_lang_class(lang) nlp = cls(meta=meta, **overrides) pipeline = meta.get("pipeline", []) disable = overrides.get("disable", [])