From b39409173e4143b6053892475c1adf6010176060 Mon Sep 17 00:00:00 2001 From: ines Date: Sat, 7 Oct 2017 00:29:08 +0200 Subject: [PATCH] Add disable option and True/False/None values for pipeline --- spacy/util.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/spacy/util.py b/spacy/util.py index 9e9c4fa42..50ebc036b 100644 --- a/spacy/util.py +++ b/spacy/util.py @@ -136,10 +136,17 @@ def load_model_from_path(model_path, meta=False, **overrides): meta = get_model_meta(model_path) cls = get_lang_class(meta['lang']) nlp = cls(meta=meta, **overrides) - for name in meta.get('pipeline', []): - config = meta.get('pipeline_args', {}).get(name, {}) - component = nlp.create_pipe(name, config=config) - nlp.add_pipe(component, name=name) + pipeline = meta.get('pipeline', []) + disable = overrides.get('disable', []) + if pipeline is True: + pipeline = nlp.Defaults.pipe_names + elif pipeline in (False, None): + pipeline = [] + for name in pipeline: + if name not in disable: + config = meta.get('pipeline_args', {}).get(name, {}) + component = nlp.create_pipe(name, config=config) + nlp.add_pipe(component, name=name) return nlp.from_disk(model_path)