mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-25 01:16:28 +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.setdefault("batch_size", batch_size)
|
||||
if not hasattr(pipe, "pipe"):
|
||||
docs = _pipe(pipe, docs, kwargs)
|
||||
docs = _pipe(docs, pipe, kwargs)
|
||||
else:
|
||||
docs = pipe.pipe(docs, **kwargs)
|
||||
for doc, gold in zip(docs, golds):
|
||||
|
|
|
@ -65,6 +65,20 @@ def test_language_evaluate(nlp):
|
|||
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):
|
||||
doc.vector += 1
|
||||
return doc
|
||||
|
|
Loading…
Reference in New Issue
Block a user