Skip to content

Commit dc30020

Browse files
author
tastelikefeet
committed
fix
1 parent 31c6dfa commit dc30020

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

swift/plugin/metric.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ def compute_rouge_bleu(preds: List[str], labels: List[str]):
123123
score_dict = {key: MeanMetric() for key in ['rouge-1', 'rouge-2', 'rouge-l', 'bleu-4']}
124124

125125
for pred, label in zip(preds, labels):
126-
hypothesis = list(jieba.cut(pred))
127-
reference = list(jieba.cut(label))
126+
hypothesis = [w.strip() for w in jieba.cut(pred) if w.strip()]
127+
reference = [w.strip() for w in jieba.cut(label) if w.strip()]
128128
if not hypothesis or not reference:
129129
continue
130130
rouge = Rouge()

0 commit comments

Comments
 (0)