Add token completion task
Browse files- codexglue.py +48 -3
- dataset_infos.json +1 -1
codexglue.py
CHANGED
@@ -43,7 +43,8 @@ _LICENSE = ""
|
|
43 |
# The HuggingFace dataset library don't host the datasets but only point to the original files
|
44 |
# This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
|
45 |
_URLs = {
|
46 |
-
'code-to-code-trans': "code-to-code-trans.zip"
|
|
|
47 |
}
|
48 |
|
49 |
|
@@ -51,7 +52,7 @@ _URLs = {
|
|
51 |
class CodeXGLUE(datasets.GeneratorBasedBuilder):
|
52 |
"""TODO: Short description of my dataset."""
|
53 |
|
54 |
-
VERSION = datasets.Version("1.0.
|
55 |
|
56 |
# This is an example of a dataset with multiple configurations.
|
57 |
# If you don't want/need to define several sub-sets in your dataset,
|
@@ -65,7 +66,10 @@ class CodeXGLUE(datasets.GeneratorBasedBuilder):
|
|
65 |
# data = datasets.load_dataset('my_dataset', 'first_domain')
|
66 |
# data = datasets.load_dataset('my_dataset', 'second_domain')
|
67 |
BUILDER_CONFIGS = [
|
68 |
-
datasets.BuilderConfig(name="code-to-code-trans", version=VERSION,
|
|
|
|
|
|
|
69 |
]
|
70 |
|
71 |
def _info(self):
|
@@ -76,6 +80,12 @@ class CodeXGLUE(datasets.GeneratorBasedBuilder):
|
|
76 |
"cs_code": datasets.Value("string")
|
77 |
}
|
78 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
else: # This is an example to show how to have different features for "first_domain" and "second_domain"
|
80 |
features = datasets.Features(
|
81 |
{
|
@@ -142,6 +152,34 @@ class CodeXGLUE(datasets.GeneratorBasedBuilder):
|
|
142 |
gen_kwargs=get_kwargs('valid')
|
143 |
),
|
144 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
|
146 |
def _generate_examples(
|
147 |
self, data_paths, split
|
@@ -164,3 +202,10 @@ class CodeXGLUE(datasets.GeneratorBasedBuilder):
|
|
164 |
'java_code': java_code,
|
165 |
'cs_code': cs_code
|
166 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
# The HuggingFace dataset library don't host the datasets but only point to the original files
|
44 |
# This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
|
45 |
_URLs = {
|
46 |
+
'code-to-code-trans': "code-to-code-trans.zip",
|
47 |
+
'code-completion-token-py150': "code-completion-token-py150.zip",
|
48 |
}
|
49 |
|
50 |
|
|
|
52 |
class CodeXGLUE(datasets.GeneratorBasedBuilder):
|
53 |
"""TODO: Short description of my dataset."""
|
54 |
|
55 |
+
VERSION = datasets.Version("1.0.1")
|
56 |
|
57 |
# This is an example of a dataset with multiple configurations.
|
58 |
# If you don't want/need to define several sub-sets in your dataset,
|
|
|
66 |
# data = datasets.load_dataset('my_dataset', 'first_domain')
|
67 |
# data = datasets.load_dataset('my_dataset', 'second_domain')
|
68 |
BUILDER_CONFIGS = [
|
69 |
+
datasets.BuilderConfig(name="code-to-code-trans", version=VERSION,
|
70 |
+
description="Java to C-sharp translation task."),
|
71 |
+
datasets.BuilderConfig(name="code-completion-token-py150", version=VERSION,
|
72 |
+
description="Token compltetion task for Python"),
|
73 |
]
|
74 |
|
75 |
def _info(self):
|
|
|
80 |
"cs_code": datasets.Value("string")
|
81 |
}
|
82 |
)
|
83 |
+
elif self.config.name == 'code-completion-token-py150':
|
84 |
+
features = datasets.Features(
|
85 |
+
{
|
86 |
+
"code": datasets.Value("string")
|
87 |
+
}
|
88 |
+
)
|
89 |
else: # This is an example to show how to have different features for "first_domain" and "second_domain"
|
90 |
features = datasets.Features(
|
91 |
{
|
|
|
152 |
gen_kwargs=get_kwargs('valid')
|
153 |
),
|
154 |
]
|
155 |
+
elif self.config.name == 'code-completion-token-py150':
|
156 |
+
data_dir = os.path.join(data_dir, self.config.name)
|
157 |
+
|
158 |
+
def get_kwargs(split_name: str):
|
159 |
+
return {
|
160 |
+
"data_paths": {
|
161 |
+
"code": os.path.join(data_dir, f'{split_name}.txt')
|
162 |
+
},
|
163 |
+
"split": split_name
|
164 |
+
}
|
165 |
+
|
166 |
+
return [
|
167 |
+
datasets.SplitGenerator(
|
168 |
+
name=datasets.Split.TRAIN,
|
169 |
+
# These kwargs will be passed to _generate_examples
|
170 |
+
gen_kwargs=get_kwargs('train')
|
171 |
+
),
|
172 |
+
datasets.SplitGenerator(
|
173 |
+
name=datasets.Split.TEST,
|
174 |
+
# These kwargs will be passed to _generate_examples
|
175 |
+
gen_kwargs=get_kwargs('test')
|
176 |
+
),
|
177 |
+
datasets.SplitGenerator(
|
178 |
+
name=datasets.Split.VALIDATION,
|
179 |
+
# These kwargs will be passed to _generate_examples
|
180 |
+
gen_kwargs=get_kwargs('dev')
|
181 |
+
),
|
182 |
+
]
|
183 |
|
184 |
def _generate_examples(
|
185 |
self, data_paths, split
|
|
|
202 |
'java_code': java_code,
|
203 |
'cs_code': cs_code
|
204 |
}
|
205 |
+
elif self.config.name == 'code-completion-token-py150':
|
206 |
+
code_path = data_paths['code']
|
207 |
+
with open(code_path, encoding='utf-8') as code_file:
|
208 |
+
for _id, code_line in enumerate(code_file):
|
209 |
+
yield _id, {
|
210 |
+
'code': code_line
|
211 |
+
}
|
dataset_infos.json
CHANGED
@@ -1 +1 @@
|
|
1 |
-
{"code-to-code-trans": {"description": "CodeXGLUE is a benchmark dataset to foster machine learning research for program understanding and generation. \nCodeXGLUE includes a collection of 10 tasks across 14 datasets and a platform for model evaluation and comparison.\n", "citation": "@article{Lu2021,\nauthor = {Lu, Shuai and Guo, Daya and Ren, Shuo and Huang, Junjie and Svyatkovskiy, Alexey and Blanco, Ambrosio and Clement, Colin B. and Drain, Dawn and Jiang, Daxin and Tang, Duyu and Li, Ge and Zhou, Lidong and Shou, Linjun and Zhou, Long and Tufano, Michele and Gong, Ming and Zhou, Ming and Duan, Nan and Sundaresan, Neel and Deng, Shao Kun and Fu, Shengyu and Liu, Shujie},\nyear = {2021},\nbooktitle = {arXiv},\ntitle = {CodeXGLUE - A Machine Learning Benchmark Dataset for Code Understanding and Generation}\n}\n", "homepage": "https://microsoft.github.io/CodeXGLUE/", "license": "", "features": {"java_code": {"dtype": "string", "id": null, "_type": "Value"}, "cs_code": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "code_xglue", "config_name": "code-to-code-trans", "version": {"version_str": "1.0.
|
|
|
1 |
+
{"code-to-code-trans": {"description": "CodeXGLUE is a benchmark dataset to foster machine learning research for program understanding and generation. \nCodeXGLUE includes a collection of 10 tasks across 14 datasets and a platform for model evaluation and comparison.\n", "citation": "@article{Lu2021,\nauthor = {Lu, Shuai and Guo, Daya and Ren, Shuo and Huang, Junjie and Svyatkovskiy, Alexey and Blanco, Ambrosio and Clement, Colin B. and Drain, Dawn and Jiang, Daxin and Tang, Duyu and Li, Ge and Zhou, Lidong and Shou, Linjun and Zhou, Long and Tufano, Michele and Gong, Ming and Zhou, Ming and Duan, Nan and Sundaresan, Neel and Deng, Shao Kun and Fu, Shengyu and Liu, Shujie},\nyear = {2021},\nbooktitle = {arXiv},\ntitle = {CodeXGLUE - A Machine Learning Benchmark Dataset for Code Understanding and Generation}\n}\n", "homepage": "https://microsoft.github.io/CodeXGLUE/", "license": "", "features": {"java_code": {"dtype": "string", "id": null, "_type": "Value"}, "cs_code": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "code_xglue", "config_name": "code-to-code-trans", "version": {"version_str": "1.0.1", "description": null, "major": 1, "minor": 0, "patch": 1}, "splits": {"train": {"name": "train", "num_bytes": 4306167, "num_examples": 10295, "dataset_name": "code_xglue"}, "test": {"name": "test", "num_bytes": 412372, "num_examples": 1000, "dataset_name": "code_xglue"}, "validation": {"name": "validation", "num_bytes": 221932, "num_examples": 499, "dataset_name": "code_xglue"}}, "download_checksums": {"code-to-code-trans.zip": {"num_bytes": 1169662, "checksum": "91000596399aee3367aab5068452e1560ab131e2c0311f3ea367e692f46fb8ac"}}, "download_size": 1169662, "post_processing_size": null, "dataset_size": 4940471, "size_in_bytes": 6110133}, "code-completion-token-py150": {"description": "CodeXGLUE is a benchmark dataset to foster machine learning research for program understanding and generation. \nCodeXGLUE includes a collection of 10 tasks across 14 datasets and a platform for model evaluation and comparison.\n", "citation": "@article{Lu2021,\nauthor = {Lu, Shuai and Guo, Daya and Ren, Shuo and Huang, Junjie and Svyatkovskiy, Alexey and Blanco, Ambrosio and Clement, Colin B. and Drain, Dawn and Jiang, Daxin and Tang, Duyu and Li, Ge and Zhou, Lidong and Shou, Linjun and Zhou, Long and Tufano, Michele and Gong, Ming and Zhou, Ming and Duan, Nan and Sundaresan, Neel and Deng, Shao Kun and Fu, Shengyu and Liu, Shujie},\nyear = {2021},\nbooktitle = {arXiv},\ntitle = {CodeXGLUE - A Machine Learning Benchmark Dataset for Code Understanding and Generation}\n}\n", "homepage": "https://microsoft.github.io/CodeXGLUE/", "license": "", "features": {"code": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "code_xglue", "config_name": "code-completion-token-py150", "version": {"version_str": "1.0.1", "description": null, "major": 1, "minor": 0, "patch": 1}, "splits": {"train": {"name": "train", "num_bytes": 441358038, "num_examples": 95000, "dataset_name": "code_xglue"}, "test": {"name": "test", "num_bytes": 228741847, "num_examples": 50000, "dataset_name": "code_xglue"}, "validation": {"name": "validation", "num_bytes": 27069231, "num_examples": 5000, "dataset_name": "code_xglue"}}, "download_checksums": {"code-completion-token-py150.zip": {"num_bytes": 102464389, "checksum": "b7a59c977da228400c6d6fec10730b9b70030248325ea325230f56280ccddb8e"}}, "download_size": 102464389, "post_processing_size": null, "dataset_size": 697169116, "size_in_bytes": 799633505}}
|