mirror of
https://github.com/explosion/spaCy.git
synced 2024-11-10 19:57:17 +03:00
Fix bug in Language.evaluate for components without .pipe (#4662)
This commit is contained in:
parent
bdfb696677
commit
3bd15055ce
|
@ -678,7 +678,7 @@ class Language(object):
|
||||||
kwargs = component_cfg.get(name, {})
|
kwargs = component_cfg.get(name, {})
|
||||||
kwargs.setdefault("batch_size", batch_size)
|
kwargs.setdefault("batch_size", batch_size)
|
||||||
if not hasattr(pipe, "pipe"):
|
if not hasattr(pipe, "pipe"):
|
||||||
docs = _pipe(pipe, docs, kwargs)
|
docs = _pipe(docs, pipe, kwargs)
|
||||||
else:
|
else:
|
||||||
docs = pipe.pipe(docs, **kwargs)
|
docs = pipe.pipe(docs, **kwargs)
|
||||||
for doc, gold in zip(docs, golds):
|
for doc, gold in zip(docs, golds):
|
||||||
|
|
|
@ -65,6 +65,20 @@ def test_language_evaluate(nlp):
|
||||||
nlp.evaluate([text, gold])
|
nlp.evaluate([text, gold])
|
||||||
|
|
||||||
|
|
||||||
|
def test_evaluate_no_pipe(nlp):
|
||||||
|
"""Test that docs are processed correctly within Language.pipe if the
|
||||||
|
component doesn't expose a .pipe method."""
|
||||||
|
|
||||||
|
def pipe(doc):
|
||||||
|
return doc
|
||||||
|
|
||||||
|
text = "hello world"
|
||||||
|
annots = {"cats": {"POSITIVE": 1.0, "NEGATIVE": 0.0}}
|
||||||
|
nlp = Language(Vocab())
|
||||||
|
nlp.add_pipe(pipe)
|
||||||
|
nlp.evaluate([(text, annots)])
|
||||||
|
|
||||||
|
|
||||||
def vector_modification_pipe(doc):
|
def vector_modification_pipe(doc):
|
||||||
doc.vector += 1
|
doc.vector += 1
|
||||||
return doc
|
return doc
|
||||||
|
|
Loading…
Reference in New Issue
Block a user