mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-26 01:46:28 +03:00
Auto-exclude disabled when calling from_disk during load (#4708)
This commit is contained in:
parent
2160ecfc92
commit
5b36dec7eb
23
spacy/tests/regression/test_issue4707.py
Normal file
23
spacy/tests/regression/test_issue4707.py
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
# coding: utf8
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from spacy.util import load_model_from_path
|
||||||
|
from spacy.lang.en import English
|
||||||
|
|
||||||
|
from ..util import make_tempdir
|
||||||
|
|
||||||
|
|
||||||
|
def test_issue4707():
|
||||||
|
"""Tests that disabled component names are also excluded from nlp.from_disk
|
||||||
|
by default when loading a model.
|
||||||
|
"""
|
||||||
|
nlp = English()
|
||||||
|
nlp.add_pipe(nlp.create_pipe("sentencizer"))
|
||||||
|
nlp.add_pipe(nlp.create_pipe("entity_ruler"))
|
||||||
|
assert nlp.pipe_names == ["sentencizer", "entity_ruler"]
|
||||||
|
exclude = ["tokenizer", "sentencizer"]
|
||||||
|
with make_tempdir() as tmpdir:
|
||||||
|
nlp.to_disk(tmpdir, exclude=exclude)
|
||||||
|
new_nlp = load_model_from_path(tmpdir, disable=exclude)
|
||||||
|
assert "sentencizer" not in new_nlp.pipe_names
|
||||||
|
assert "entity_ruler" in new_nlp.pipe_names
|
|
@ -208,7 +208,7 @@ def load_model_from_path(model_path, meta=False, **overrides):
|
||||||
factory = factories.get(name, name)
|
factory = factories.get(name, name)
|
||||||
component = nlp.create_pipe(factory, config=config)
|
component = nlp.create_pipe(factory, config=config)
|
||||||
nlp.add_pipe(component, name=name)
|
nlp.add_pipe(component, name=name)
|
||||||
return nlp.from_disk(model_path)
|
return nlp.from_disk(model_path, exclude=disable)
|
||||||
|
|
||||||
|
|
||||||
def load_model_from_init_py(init_file, **overrides):
|
def load_model_from_init_py(init_file, **overrides):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user