merge dicts instead of overwrite

This commit is contained in:
svlandeg 2022-11-17 12:52:00 +01:00
parent 8344143012
commit 89bee0ed77
1 changed files with 5 additions and 1 deletions

View File

@ -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