Skip to content

Commit

Permalink
fix jieba rouge (#467)
Browse files Browse the repository at this point in the history
  • Loading branch information
Leymore authored Oct 12, 2023
1 parent d7ff933 commit 362c33d
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ def score(self, predictions, references):
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 {
Expand Down

0 comments on commit 362c33d

Please sign in to comment.