mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-26 18:06:29 +03:00
Merge pull request #5491 from explosion/chore/rename-pipe-analysis
This commit is contained in:
commit
15d3a0ac3a
|
@ -17,8 +17,8 @@ from .tokens.underscore import Underscore
|
||||||
from .vocab import Vocab
|
from .vocab import Vocab
|
||||||
from .lemmatizer import Lemmatizer
|
from .lemmatizer import Lemmatizer
|
||||||
from .lookups import Lookups
|
from .lookups import Lookups
|
||||||
from .analysis import analyze_pipes, analyze_all_pipes, validate_attrs
|
from .pipe_analysis import analyze_pipes, analyze_all_pipes, validate_attrs
|
||||||
from .analysis import count_pipeline_interdependencies
|
from .pipe_analysis import count_pipeline_interdependencies
|
||||||
from .gold import Example
|
from .gold import Example
|
||||||
from .scorer import Scorer
|
from .scorer import Scorer
|
||||||
from .util import link_vectors_to_models, create_default_optimizer, registry
|
from .util import link_vectors_to_models, create_default_optimizer, registry
|
||||||
|
@ -318,14 +318,18 @@ class Language(object):
|
||||||
|
|
||||||
# check whether we have a proper model config, or load a default one
|
# check whether we have a proper model config, or load a default one
|
||||||
if "model" in factory_cfg and not isinstance(factory_cfg["model"], dict):
|
if "model" in factory_cfg and not isinstance(factory_cfg["model"], dict):
|
||||||
warnings.warn(Warnings.W099.format(type=type(factory_cfg["model"]), pipe=name))
|
warnings.warn(
|
||||||
|
Warnings.W099.format(type=type(factory_cfg["model"]), pipe=name)
|
||||||
|
)
|
||||||
|
|
||||||
# refer to the model configuration in the cfg settings for this component
|
# refer to the model configuration in the cfg settings for this component
|
||||||
if "model" in factory_cfg:
|
if "model" in factory_cfg:
|
||||||
self.config[name] = {"model": factory_cfg["model"]}
|
self.config[name] = {"model": factory_cfg["model"]}
|
||||||
|
|
||||||
# create all objects in the config
|
# create all objects in the config
|
||||||
factory_cfg = registry.make_from_config({"config": factory_cfg}, validate=True)["config"]
|
factory_cfg = registry.make_from_config({"config": factory_cfg}, validate=True)[
|
||||||
|
"config"
|
||||||
|
]
|
||||||
model = factory_cfg.get("model", None)
|
model = factory_cfg.get("model", None)
|
||||||
if model is not None:
|
if model is not None:
|
||||||
del factory_cfg["model"]
|
del factory_cfg["model"]
|
||||||
|
@ -519,7 +523,16 @@ class Language(object):
|
||||||
def make_doc(self, text):
|
def make_doc(self, text):
|
||||||
return self.tokenizer(text)
|
return self.tokenizer(text)
|
||||||
|
|
||||||
def update(self, examples, dummy=None, *, drop=0.0, sgd=None, losses=None, component_cfg=None):
|
def update(
|
||||||
|
self,
|
||||||
|
examples,
|
||||||
|
dummy=None,
|
||||||
|
*,
|
||||||
|
drop=0.0,
|
||||||
|
sgd=None,
|
||||||
|
losses=None,
|
||||||
|
component_cfg=None,
|
||||||
|
):
|
||||||
"""Update the models in the pipeline.
|
"""Update the models in the pipeline.
|
||||||
|
|
||||||
examples (iterable): A batch of `Example` or `Doc` objects.
|
examples (iterable): A batch of `Example` or `Doc` objects.
|
||||||
|
|
|
@ -187,10 +187,8 @@ def count_pipeline_interdependencies(pipeline):
|
||||||
counts = []
|
counts = []
|
||||||
for i, assigns in enumerate(pipe_assigns):
|
for i, assigns in enumerate(pipe_assigns):
|
||||||
count = 0
|
count = 0
|
||||||
for requires in pipe_requires[i+1:]:
|
for requires in pipe_requires[i + 1 :]:
|
||||||
if assigns.intersection(requires):
|
if assigns.intersection(requires):
|
||||||
count += 1
|
count += 1
|
||||||
counts.append(count)
|
counts.append(count)
|
||||||
return counts
|
return counts
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import spacy.language
|
import spacy.language
|
||||||
from spacy.language import Language, component
|
from spacy.language import Language, component
|
||||||
from spacy.analysis import print_summary, validate_attrs
|
from spacy.pipe_analysis import print_summary, validate_attrs
|
||||||
from spacy.analysis import get_assigns_for_attr, get_requires_for_attr
|
from spacy.pipe_analysis import get_assigns_for_attr, get_requires_for_attr
|
||||||
from spacy.analysis import count_pipeline_interdependencies
|
from spacy.pipe_analysis import count_pipeline_interdependencies
|
||||||
from mock import Mock, ANY
|
from mock import Mock, ANY
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user