Delete codebleu.py
Browse files- codebleu.py +0 -104
codebleu.py
DELETED
@@ -1,104 +0,0 @@
|
|
1 |
-
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
|
2 |
-
#
|
3 |
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4 |
-
# you may not use this file except in compliance with the License.
|
5 |
-
# You may obtain a copy of the License at
|
6 |
-
#
|
7 |
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8 |
-
#
|
9 |
-
# Unless required by applicable law or agreed to in writing, software
|
10 |
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11 |
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
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 evaluate
|
17 |
-
import datasets
|
18 |
-
from .calc_code_bleu import calculate
|
19 |
-
import os
|
20 |
-
|
21 |
-
|
22 |
-
# TODO: Add BibTeX citation
|
23 |
-
_CITATION = """\
|
24 |
-
@InProceedings{huggingface:module,
|
25 |
-
title = {A great new module},
|
26 |
-
authors={huggingface, Inc.},
|
27 |
-
year={2020}
|
28 |
-
}
|
29 |
-
"""
|
30 |
-
|
31 |
-
# TODO: Add description of the module here
|
32 |
-
_DESCRIPTION = """\
|
33 |
-
This new module is designed to solve this great ML task and is crafted with a lot of care.
|
34 |
-
"""
|
35 |
-
|
36 |
-
|
37 |
-
# TODO: Add description of the arguments of the module here
|
38 |
-
_KWARGS_DESCRIPTION = """
|
39 |
-
Calculates how good are predictions given some references, using certain scores
|
40 |
-
Args:
|
41 |
-
predictions: list of predictions to score. Each predictions
|
42 |
-
should be a string with tokens separated by spaces.
|
43 |
-
references: list of reference for each prediction. Each
|
44 |
-
reference should be a string with tokens separated by spaces.
|
45 |
-
Returns:
|
46 |
-
accuracy: description of the first score,
|
47 |
-
another_score: description of the second score,
|
48 |
-
Examples:
|
49 |
-
Examples should be written in doctest format, and should illustrate how
|
50 |
-
to use the function.
|
51 |
-
|
52 |
-
>>> my_new_module = evaluate.load("my_new_module")
|
53 |
-
>>> results = my_new_module.compute(references=[0, 1], predictions=[0, 1])
|
54 |
-
>>> print(results)
|
55 |
-
{'accuracy': 1.0}
|
56 |
-
"""
|
57 |
-
|
58 |
-
# TODO: Define external resources urls if needed
|
59 |
-
BAD_WORDS_URL = "http://url/to/external/resource/bad_words.txt"
|
60 |
-
|
61 |
-
|
62 |
-
@evaluate.utils.file_utils.add_start_docstrings(_DESCRIPTION, _KWARGS_DESCRIPTION)
|
63 |
-
class CodeBLEU(evaluate.Metric):
|
64 |
-
"""TODO: Short description of my evaluation module."""
|
65 |
-
|
66 |
-
def _info(self):
|
67 |
-
# TODO: Specifies the evaluate.EvaluationModuleInfo object
|
68 |
-
return evaluate.MetricInfo(
|
69 |
-
# This is the description that will appear on the modules page.
|
70 |
-
module_type="metric",
|
71 |
-
description=_DESCRIPTION,
|
72 |
-
citation=_CITATION,
|
73 |
-
inputs_description=_KWARGS_DESCRIPTION,
|
74 |
-
# This defines the format of each prediction and reference
|
75 |
-
features=datasets.Features({
|
76 |
-
'predictions': datasets.Value('string'),
|
77 |
-
'references': datasets.Sequence(datasets.Value("string")),
|
78 |
-
}),
|
79 |
-
# Homepage of the module for documentation
|
80 |
-
homepage="http://module.homepage",
|
81 |
-
# Additional links to the codebase or references
|
82 |
-
codebase_urls=["http://github.com/path/to/codebase/of/new_module"],
|
83 |
-
reference_urls=["http://path.to.reference.url/new_module"]
|
84 |
-
)
|
85 |
-
'''
|
86 |
-
def _download_and_prepare(self, dl_manager):
|
87 |
-
dl_manager.download("https://huggingface.co/spaces/giulio98/codebleu/blob/main/bleu.py")
|
88 |
-
dl_manager.download("https://giulio98:[email protected]/spaces/giulio98/codebleu/blob/main/dataflow_match.py")
|
89 |
-
dl_manager.download("https://giulio98:[email protected]/spaces/giulio98/codebleu/blob/main/syntax_match.py")
|
90 |
-
dl_manager.download("https://giulio98:[email protected]/spaces/giulio98/codebleu/blob/main/utils.py")
|
91 |
-
dl_manager.download("https://giulio98:[email protected]/spaces/giulio98/codebleu/blob/main/weighted_ngram_match.py")
|
92 |
-
dl_manager.download("https://giulio98:[email protected]/spaces/giulio98/codebleu/blob/main/keywords/cpp.txt")
|
93 |
-
dl_manager.download("https://giulio98:[email protected]/spaces/giulio98/codebleu/blob/main/keywords/python.txt")
|
94 |
-
dl_manager.download("https://giulio98:[email protected]/spaces/giulio98/codebleu/blob/main/parsercode/DFG.py")
|
95 |
-
dl_manager.download("https://giulio98:[email protected]/spaces/giulio98/codebleu/blob/main/parsercode/__init__.py")
|
96 |
-
dl_manager.download("https://giulio98:[email protected]/spaces/giulio98/codebleu/blob/main/parsercode/build.py")
|
97 |
-
dl_manager.download("https://giulio98:[email protected]/spaces/giulio98/codebleu/blob/main/parsercode/build.sh")
|
98 |
-
dl_manager.download("https://giulio98:[email protected]/spaces/giulio98/codebleu/blob/main/parsercode/utils.py")
|
99 |
-
'''
|
100 |
-
|
101 |
-
|
102 |
-
def _compute(self, predictions, references, language="python", alpha=0.25, beta=0.25, gamma=0.25, theta=0.25):
|
103 |
-
|
104 |
-
return calculate(predictions, references, language, alpha, beta, gamma, theta)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|