From 50a27509a394a42605b0231a7ceeffe0fb9b77f3 Mon Sep 17 00:00:00 2001 From: hiyouga Date: Thu, 6 Jul 2023 14:28:34 +0800 Subject: [PATCH] fix rouge score Former-commit-id: caa00d3ac24c989d56887af9d7ca79244e72714a --- src/utils/seq2seq.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/seq2seq.py b/src/utils/seq2seq.py index 53b12f38..cab7a919 100644 --- a/src/utils/seq2seq.py +++ b/src/utils/seq2seq.py @@ -46,7 +46,7 @@ class ComputeMetrics: hypothesis = list(jieba.cut(pred)) reference = list(jieba.cut(label)) - if len(" ".join(hypothesis).split()) == 0: + if len(" ".join(hypothesis).split()) == 0 or len(" ".join(reference).split()) == 0: result = {"rouge-1": {"f": 0.0}, "rouge-2": {"f": 0.0}, "rouge-l": {"f": 0.0}} else: rouge = Rouge()