From a0cdc2b007799317e3d8691b31de045dd8a893d1 Mon Sep 17 00:00:00 2001 From: Adriane Boyd Date: Mon, 6 Dec 2021 20:39:15 +0100 Subject: [PATCH] Use Language.pipe in evaluate (#9800) --- spacy/language.py | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/spacy/language.py b/spacy/language.py index 204b24ecb..638616316 100644 --- a/spacy/language.py +++ b/spacy/language.py @@ -1404,20 +1404,13 @@ class Language: for eg in examples: self.make_doc(eg.reference.text) # apply all pipeline components - for name, pipe in self.pipeline: - kwargs = component_cfg.get(name, {}) - kwargs.setdefault("batch_size", batch_size) - for doc, eg in zip( - _pipe( - (eg.predicted for eg in examples), - proc=pipe, - name=name, - default_error_handler=self.default_error_handler, - kwargs=kwargs, - ), - examples, - ): - eg.predicted = doc + docs = self.pipe( + (eg.predicted for eg in examples), + batch_size=batch_size, + component_cfg=component_cfg, + ) + for eg, doc in zip(examples, docs): + eg.predicted = doc end_time = timer() results = scorer.score(examples) n_words = sum(len(eg.predicted) for eg in examples)