mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-26 01:46:28 +03:00
Add disable option and True/False/None values for pipeline
This commit is contained in:
parent
2586b61b15
commit
b39409173e
|
@ -136,7 +136,14 @@ def load_model_from_path(model_path, meta=False, **overrides):
|
||||||
meta = get_model_meta(model_path)
|
meta = get_model_meta(model_path)
|
||||||
cls = get_lang_class(meta['lang'])
|
cls = get_lang_class(meta['lang'])
|
||||||
nlp = cls(meta=meta, **overrides)
|
nlp = cls(meta=meta, **overrides)
|
||||||
for name in meta.get('pipeline', []):
|
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, {})
|
config = meta.get('pipeline_args', {}).get(name, {})
|
||||||
component = nlp.create_pipe(name, config=config)
|
component = nlp.create_pipe(name, config=config)
|
||||||
nlp.add_pipe(component, name=name)
|
nlp.add_pipe(component, name=name)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user