Spaces:
Runtime error
Runtime error
github-actions
commited on
Commit
·
48fa02d
1
Parent(s):
695eff8
Auto files update [main]
Browse files- codebleu.py +5 -4
codebleu.py
CHANGED
@@ -12,11 +12,11 @@
|
|
12 |
# See the License for the specific language governing permissions and
|
13 |
# limitations under the License.
|
14 |
"""TODO: Add a description here."""
|
|
|
15 |
|
16 |
import datasets
|
17 |
import evaluate
|
18 |
|
19 |
-
from codebleu import calc_codebleu
|
20 |
|
21 |
# TODO: Add BibTeX citation
|
22 |
_CITATION = """\
|
@@ -47,7 +47,7 @@ Args:
|
|
47 |
should be a string with tokens separated by spaces.
|
48 |
references: list of reference for each prediction. Each
|
49 |
reference should be a string with tokens separated by spaces.
|
50 |
-
language: programming language in ['java','js','c_sharp','php','
|
51 |
weights: tuple of 4 floats to use as weights for scores. Defaults to (0.25, 0.25, 0.25, 0.25).
|
52 |
Returns:
|
53 |
codebleu: resulting `CodeBLEU` score,
|
@@ -110,12 +110,13 @@ class codebleu(evaluate.Metric):
|
|
110 |
|
111 |
def _download_and_prepare(self, dl_manager):
|
112 |
"""Optional: download external resources useful to compute the scores"""
|
113 |
-
#
|
|
|
114 |
pass
|
115 |
|
116 |
def _compute(self, predictions, references, lang, weights=(0.25, 0.25, 0.25, 0.25), tokenizer=None):
|
117 |
"""Returns the scores"""
|
118 |
-
return calc_codebleu(
|
119 |
references=references,
|
120 |
predictions=predictions,
|
121 |
lang=lang,
|
|
|
12 |
# See the License for the specific language governing permissions and
|
13 |
# limitations under the License.
|
14 |
"""TODO: Add a description here."""
|
15 |
+
import importlib
|
16 |
|
17 |
import datasets
|
18 |
import evaluate
|
19 |
|
|
|
20 |
|
21 |
# TODO: Add BibTeX citation
|
22 |
_CITATION = """\
|
|
|
47 |
should be a string with tokens separated by spaces.
|
48 |
references: list of reference for each prediction. Each
|
49 |
reference should be a string with tokens separated by spaces.
|
50 |
+
language: programming language in ['java','js','c_sharp','php','c','python','cpp'].
|
51 |
weights: tuple of 4 floats to use as weights for scores. Defaults to (0.25, 0.25, 0.25, 0.25).
|
52 |
Returns:
|
53 |
codebleu: resulting `CodeBLEU` score,
|
|
|
110 |
|
111 |
def _download_and_prepare(self, dl_manager):
|
112 |
"""Optional: download external resources useful to compute the scores"""
|
113 |
+
# workarounds as this file have to be named codebleu (evaluate library requirement)
|
114 |
+
self.codebleu_package = importlib.import_module('codebleu')
|
115 |
pass
|
116 |
|
117 |
def _compute(self, predictions, references, lang, weights=(0.25, 0.25, 0.25, 0.25), tokenizer=None):
|
118 |
"""Returns the scores"""
|
119 |
+
return self.codebleu_package.calc_codebleu(
|
120 |
references=references,
|
121 |
predictions=predictions,
|
122 |
lang=lang,
|