fix: create BLEUScore for each n-gram
Browse files- bleu_1234.py +9 -5
bleu_1234.py
CHANGED
@@ -103,11 +103,15 @@ class bleu_1234(evaluate.Metric):
|
|
103 |
if isinstance(references[0], str):
|
104 |
references = [[ref] for ref in references]
|
105 |
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
|
|
|
|
|
|
|
|
111 |
|
112 |
output_dict = {
|
113 |
"bleu-1": bleu1,
|
|
|
103 |
if isinstance(references[0], str):
|
104 |
references = [[ref] for ref in references]
|
105 |
|
106 |
+
bleu_score_1 = BLEUScore(n_gram=1)
|
107 |
+
bleu_score_2 = BLEUScore(n_gram=2)
|
108 |
+
bleu_score_3 = BLEUScore(n_gram=3)
|
109 |
+
bleu_score_4 = BLEUScore(n_gram=4)
|
110 |
+
|
111 |
+
bleu1 = bleu_score_1(predictions, references, n_gram=1)
|
112 |
+
bleu2 = bleu_score_2(predictions, references, n_gram=2)
|
113 |
+
bleu3 = bleu_score_3(predictions, references, n_gram=3)
|
114 |
+
bleu4 = bleu_score_4(predictions, references, n_gram=4)
|
115 |
|
116 |
output_dict = {
|
117 |
"bleu-1": bleu1,
|