fix jieba rouge (#467)

This commit is contained in:
Leymore 2023-10-11 21:25:19 -05:00 committed by GitHub
parent d7ff933a73
commit 362c33dff4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -30,6 +30,11 @@ class JiebaRougeEvaluator(BaseEvaluator):
metric = Rouge()
predictions = [' '.join(jieba.cut(i)) for i in predictions]
references = [' '.join(jieba.cut(i)) for i in references]
# avoid raising error when empty string encountered
predictions = [i if i else '__PREDPLACEHOLDER__' for i in predictions]
references = [i if i else '__REFRPLACEHOLDER__' for i in references]
score = metric.get_scores(predictions, references, avg=True)
return {