Datasets:
Delete loading script
Browse files- code_x_glue_tt_text_to_text.py +0 -106
code_x_glue_tt_text_to_text.py
DELETED
@@ -1,106 +0,0 @@
|
|
1 |
-
from typing import List
|
2 |
-
|
3 |
-
import datasets
|
4 |
-
|
5 |
-
from .common import Child
|
6 |
-
from .generated_definitions import DEFINITIONS
|
7 |
-
|
8 |
-
|
9 |
-
_DESCRIPTION = """The dataset we use is crawled and filtered from Microsoft Documentation, whose document located at https://github.com/MicrosoftDocs/."""
|
10 |
-
_CITATION = """@article{DBLP:journals/corr/abs-2102-04664,
|
11 |
-
author = {Shuai Lu and
|
12 |
-
Daya Guo and
|
13 |
-
Shuo Ren and
|
14 |
-
Junjie Huang and
|
15 |
-
Alexey Svyatkovskiy and
|
16 |
-
Ambrosio Blanco and
|
17 |
-
Colin B. Clement and
|
18 |
-
Dawn Drain and
|
19 |
-
Daxin Jiang and
|
20 |
-
Duyu Tang and
|
21 |
-
Ge Li and
|
22 |
-
Lidong Zhou and
|
23 |
-
Linjun Shou and
|
24 |
-
Long Zhou and
|
25 |
-
Michele Tufano and
|
26 |
-
Ming Gong and
|
27 |
-
Ming Zhou and
|
28 |
-
Nan Duan and
|
29 |
-
Neel Sundaresan and
|
30 |
-
Shao Kun Deng and
|
31 |
-
Shengyu Fu and
|
32 |
-
Shujie Liu},
|
33 |
-
title = {CodeXGLUE: {A} Machine Learning Benchmark Dataset for Code Understanding
|
34 |
-
and Generation},
|
35 |
-
journal = {CoRR},
|
36 |
-
volume = {abs/2102.04664},
|
37 |
-
year = {2021}
|
38 |
-
}"""
|
39 |
-
|
40 |
-
|
41 |
-
class CodeXGlueTtTextToTextImpl(Child):
|
42 |
-
_DESCRIPTION = _DESCRIPTION
|
43 |
-
_CITATION = _CITATION
|
44 |
-
|
45 |
-
_FEATURES = {
|
46 |
-
"id": datasets.Value("int32"), # The index of the sample
|
47 |
-
"source": datasets.Value("string"), # The source language version of the text
|
48 |
-
"target": datasets.Value("string"), # The target language version of the text
|
49 |
-
}
|
50 |
-
|
51 |
-
_SUPERVISED_KEYS = ["target"]
|
52 |
-
|
53 |
-
KEYS = ["source", "target"]
|
54 |
-
|
55 |
-
SPLITS = {"train": datasets.Split.TRAIN, "dev": datasets.Split.VALIDATION, "test": datasets.Split.TEST}
|
56 |
-
|
57 |
-
def generate_urls(self, split_name):
|
58 |
-
lang_pair = self.info["parameters"]["natural_language_pair"]
|
59 |
-
for i, lang in enumerate(lang_pair.split("-")):
|
60 |
-
yield self.KEYS[i], f"{split_name}/{lang_pair}.{split_name}.{lang}"
|
61 |
-
|
62 |
-
def _generate_examples(self, split_name, file_paths):
|
63 |
-
# Open each file (one for source language and the other for target language)
|
64 |
-
files = {k: open(file_paths[k], encoding="utf-8") for k in file_paths}
|
65 |
-
|
66 |
-
id_ = 0
|
67 |
-
while True:
|
68 |
-
# Read a single line from each file
|
69 |
-
entries = {k: files[k].readline() for k in file_paths}
|
70 |
-
|
71 |
-
empty = self.check_empty(entries)
|
72 |
-
if empty:
|
73 |
-
# We are done: end of files
|
74 |
-
return
|
75 |
-
|
76 |
-
entries["id"] = id_
|
77 |
-
yield id_, entries
|
78 |
-
id_ += 1
|
79 |
-
|
80 |
-
|
81 |
-
CLASS_MAPPING = {
|
82 |
-
"CodeXGlueTtTextToText": CodeXGlueTtTextToTextImpl,
|
83 |
-
}
|
84 |
-
|
85 |
-
|
86 |
-
class CodeXGlueTtTextToText(datasets.GeneratorBasedBuilder):
|
87 |
-
BUILDER_CONFIG_CLASS = datasets.BuilderConfig
|
88 |
-
BUILDER_CONFIGS = [
|
89 |
-
datasets.BuilderConfig(name=name, description=info["description"]) for name, info in DEFINITIONS.items()
|
90 |
-
]
|
91 |
-
|
92 |
-
def _info(self):
|
93 |
-
name = self.config.name
|
94 |
-
info = DEFINITIONS[name]
|
95 |
-
if info["class_name"] in CLASS_MAPPING:
|
96 |
-
self.child = CLASS_MAPPING[info["class_name"]](info)
|
97 |
-
else:
|
98 |
-
raise RuntimeError(f"Unknown python class for dataset configuration {name}")
|
99 |
-
ret = self.child._info()
|
100 |
-
return ret
|
101 |
-
|
102 |
-
def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
|
103 |
-
return self.child._split_generators(dl_manager=dl_manager)
|
104 |
-
|
105 |
-
def _generate_examples(self, split_name, file_paths):
|
106 |
-
return self.child._generate_examples(split_name, file_paths)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|