File tree 1 file changed +4
-2
lines changed
1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -65,20 +65,22 @@ def bleu(targets, predictions):
65
65
return {"bleu" : bleu_score .score }
66
66
67
67
68
- def rouge (targets , predictions , score_keys = None ):
68
+ def rouge (targets , predictions , score_keys = None , spm_model = None ):
69
69
"""Computes rouge score.
70
70
71
71
Args:
72
72
targets: list of strings
73
73
predictions: list of strings
74
74
score_keys: list of strings with the keys to compute.
75
+ spm_model: string, path to SentencePieceModel model. If provided, this model
76
+ is used for tokenizing the targets and predictions.
75
77
Returns:
76
78
dict with score_key: rouge score across all targets and predictions
77
79
"""
78
80
79
81
if score_keys is None :
80
82
score_keys = ["rouge1" , "rouge2" , "rougeLsum" ]
81
- scorer = rouge_scorer .RougeScorer (score_keys )
83
+ scorer = rouge_scorer .RougeScorer (score_keys , spm_model = spm_model )
82
84
aggregator = scoring .BootstrapAggregator ()
83
85
84
86
def _prepare_summary (summary ):
You can’t perform that action at this time.
0 commit comments