Update codebleu.py
Browse files- codebleu.py +4 -3
codebleu.py
CHANGED
@@ -110,9 +110,10 @@ class CodeBLEU(evaluate.Metric):
|
|
110 |
def _compute(self, predictions, references, language="python", alpha=0.25, beta=0.25, gamma=0.25, theta=0.25):
|
111 |
|
112 |
# preprocess inputs
|
113 |
-
pre_references = [[
|
114 |
-
|
115 |
-
hypothesis = [
|
|
|
116 |
|
117 |
for i in range(len(pre_references)):
|
118 |
assert len(hypothesis) == len(pre_references[i])
|
|
|
110 |
def _compute(self, predictions, references, language="python", alpha=0.25, beta=0.25, gamma=0.25, theta=0.25):
|
111 |
|
112 |
# preprocess inputs
|
113 |
+
pre_references = [[s.strip() for s in my_list] for my_list in references]
|
114 |
+
#pre_references = [[x.strip() for x in open(file, 'r', encoding='utf-8').readlines()] for file in references]
|
115 |
+
hypothesis = [s.strip() for s in predictions]
|
116 |
+
#hypothesis = [x.strip() for x in open(predictions, 'r', encoding='utf-8').readlines()]
|
117 |
|
118 |
for i in range(len(pre_references)):
|
119 |
assert len(hypothesis) == len(pre_references[i])
|