From 89bee0ed7798389e6de882a0234e6075fbdaf331 Mon Sep 17 00:00:00 2001 From: svlandeg Date: Thu, 17 Nov 2022 12:52:00 +0100 Subject: [PATCH] merge dicts instead of overwrite --- spacy/scorer.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spacy/scorer.py b/spacy/scorer.py index 16fc303a0..e211c3ad4 100644 --- a/spacy/scorer.py +++ b/spacy/scorer.py @@ -134,7 +134,11 @@ class Scorer: scores.update(self.nlp.tokenizer.score(examples, **self.cfg)) # type: ignore for name, component in self.nlp.pipeline: if hasattr(component, "score"): - scores.update(component.score(examples, **self.cfg)) + comp_sc = component.score(examples, **self.cfg) + for k, v in comp_sc.items(): + if isinstance(v, dict): + scores[k] = {**scores.get(k, {}), **v} + scores.update({k: v for k, v in comp_sc.items() if not isinstance(v, dict)}) return scores @staticmethod