From 601b1747d1230cdd4c4aed36f28f0088b52a9fd0 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: b84b03a2a5ca72ce0ba71d9a9c3db1a687283fa6 --- 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()