Skip to content

Commit

Permalink
MacroF1 add verbose_score to JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
thammegowda committed Sep 22, 2021
1 parent 8f007c7 commit 4850cdc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sacrebleu/metrics/clseval.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,16 @@ def format(self, width=2, score_only=False, signature='', is_json: bool = False)
len_ratio=round(self.hyp_len / self.ref_len, max(width, 3)) if self.ref_len else -1,
hyp_len=self.hyp_len,
ref_len=self.ref_len)
verbose_score = ' '.join(f'{k} = {v}' for k, v in extra.items())
if score_only:
pass
elif is_json:
res = json.loads(res)
res.update(extra)
res['verbose_score'] = verbose_score
res = json.dumps(res, indent=1, ensure_ascii=False)
else:
res += ' ' + ' '.join(f'{k} = {v}' for k, v in extra.items())
res += ' ' + verbose_score
return res

def write_report(self, path):
Expand Down

0 comments on commit 4850cdc

Please sign in to comment.