mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-13 18:56:36 +03:00
Merge branch 'master' of https://github.com/explosion/spaCy
This commit is contained in:
commit
6b1126c312
|
@ -20,13 +20,16 @@ def validate():
|
||||||
prints("Couldn't fetch compatibility table.",
|
prints("Couldn't fetch compatibility table.",
|
||||||
title="Server error (%d)" % r.status_code, exits=1)
|
title="Server error (%d)" % r.status_code, exits=1)
|
||||||
compat = r.json()['spacy']
|
compat = r.json()['spacy']
|
||||||
|
current_compat = compat.get(about.__version__)
|
||||||
|
if not current_compat:
|
||||||
|
prints(about.__compatibility__, exits=1,
|
||||||
|
title="Can't find spaCy v{} in compatibility table"
|
||||||
|
.format(about.__version__))
|
||||||
all_models = set()
|
all_models = set()
|
||||||
for spacy_v, models in dict(compat).items():
|
for spacy_v, models in dict(compat).items():
|
||||||
all_models.update(models.keys())
|
all_models.update(models.keys())
|
||||||
for model, model_vs in models.items():
|
for model, model_vs in models.items():
|
||||||
compat[spacy_v][model] = [reformat_version(v) for v in model_vs]
|
compat[spacy_v][model] = [reformat_version(v) for v in model_vs]
|
||||||
|
|
||||||
current_compat = compat[about.__version__]
|
|
||||||
model_links = get_model_links(current_compat)
|
model_links = get_model_links(current_compat)
|
||||||
model_pkgs = get_model_pkgs(current_compat, all_models)
|
model_pkgs = get_model_pkgs(current_compat, all_models)
|
||||||
incompat_links = {l for l, d in model_links.items() if not d['compat']}
|
incompat_links = {l for l, d in model_links.items() if not d['compat']}
|
||||||
|
|
|
@ -236,6 +236,14 @@ class Language(object):
|
||||||
>>> nlp.add_pipe(component, before='ner')
|
>>> nlp.add_pipe(component, before='ner')
|
||||||
>>> nlp.add_pipe(component, name='custom_name', last=True)
|
>>> nlp.add_pipe(component, name='custom_name', last=True)
|
||||||
"""
|
"""
|
||||||
|
if not hasattr(component, '__call__'):
|
||||||
|
msg = ("Not a valid pipeline component. Expected callable, but "
|
||||||
|
"got {}. ".format(repr(component)))
|
||||||
|
if isinstance(component, basestring_) and component in self.factories:
|
||||||
|
msg += ("If you meant to add a built-in component, use "
|
||||||
|
"create_pipe: nlp.add_pipe(nlp.create_pipe('{}'))"
|
||||||
|
.format(component))
|
||||||
|
raise ValueError(msg)
|
||||||
if name is None:
|
if name is None:
|
||||||
if hasattr(component, 'name'):
|
if hasattr(component, 'name'):
|
||||||
name = component.name
|
name = component.name
|
||||||
|
|
|
@ -107,3 +107,9 @@ def test_add_lots_of_pipes(nlp, n_pipes):
|
||||||
for i in range(n_pipes):
|
for i in range(n_pipes):
|
||||||
nlp.add_pipe(lambda doc: doc, name='pipe_%d' % i)
|
nlp.add_pipe(lambda doc: doc, name='pipe_%d' % i)
|
||||||
assert len(nlp.pipe_names) == n_pipes
|
assert len(nlp.pipe_names) == n_pipes
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('component', ['ner', {'hello': 'world'}])
|
||||||
|
def test_raise_for_invalid_components(nlp, component):
|
||||||
|
with pytest.raises(ValueError):
|
||||||
|
nlp.add_pipe(component)
|
||||||
|
|
|
@ -238,7 +238,7 @@ p
|
||||||
python -m pytest <spacy-directory> --models --en # basic and English model tests
|
python -m pytest <spacy-directory> --models --en # basic and English model tests
|
||||||
|
|
||||||
+infobox("Note on model tests", "⚠️")
|
+infobox("Note on model tests", "⚠️")
|
||||||
| The test suite specifies a #[+a(gh("spacy", "tests/conftest.py")) list of models]
|
| The test suite specifies a #[+a(gh("spacy", "spacy/tests/conftest.py")) list of models]
|
||||||
| to run the tests on. If a model is not installed, the tests will be
|
| to run the tests on. If a model is not installed, the tests will be
|
||||||
| skipped. If all models are installed, the respective tests will run once
|
| skipped. If all models are installed, the respective tests will run once
|
||||||
| for each model. The easiest way to find out which models and model
|
| for each model. The easiest way to find out which models and model
|
||||||
|
|
Loading…
Reference in New Issue
Block a user