Datasets:
Tasks:
Translation
Modalities:
Text
Formats:
parquet
Size:
100K - 1M
ArXiv:
Tags:
text-to-code
License:
Delete loading script
Browse files
code_x_glue_tc_text_to_code.py
DELETED
|
@@ -1,69 +0,0 @@
|
|
| 1 |
-
import json
|
| 2 |
-
from typing import List
|
| 3 |
-
|
| 4 |
-
import datasets
|
| 5 |
-
|
| 6 |
-
from .common import Child
|
| 7 |
-
from .generated_definitions import DEFINITIONS
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
_DESCRIPTION = """We use concode dataset which is a widely used code generation dataset from Iyer's EMNLP 2018 paper Mapping Language to Code in Programmatic Context. See paper for details."""
|
| 11 |
-
_CITATION = """@article{iyer2018mapping,
|
| 12 |
-
title={Mapping language to code in programmatic context},
|
| 13 |
-
author={Iyer, Srinivasan and Konstas, Ioannis and Cheung, Alvin and Zettlemoyer, Luke},
|
| 14 |
-
journal={arXiv preprint arXiv:1808.09588},
|
| 15 |
-
year={2018}
|
| 16 |
-
}"""
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
class CodeXGlueTcTextToCodeImpl(Child):
|
| 20 |
-
_DESCRIPTION = _DESCRIPTION
|
| 21 |
-
_CITATION = _CITATION
|
| 22 |
-
|
| 23 |
-
_FEATURES = {
|
| 24 |
-
"id": datasets.Value("int32"), # Index of the sample
|
| 25 |
-
"nl": datasets.Value("string"), # The natural language description of the task
|
| 26 |
-
"code": datasets.Value("string"), # The programming source code for the task
|
| 27 |
-
}
|
| 28 |
-
|
| 29 |
-
_SUPERVISED_KEYS = ["code"]
|
| 30 |
-
|
| 31 |
-
SPLITS = {"train": datasets.Split.TRAIN, "dev": datasets.Split.VALIDATION, "test": datasets.Split.TEST}
|
| 32 |
-
|
| 33 |
-
def generate_urls(self, split_name):
|
| 34 |
-
yield "data", f"concode/{split_name}.json"
|
| 35 |
-
|
| 36 |
-
def _generate_examples(self, split_name, file_paths):
|
| 37 |
-
with open(file_paths["data"], encoding="utf-8") as f:
|
| 38 |
-
for idx, line in enumerate(f):
|
| 39 |
-
entry = json.loads(line)
|
| 40 |
-
entry["id"] = idx
|
| 41 |
-
yield idx, entry
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
CLASS_MAPPING = {
|
| 45 |
-
"CodeXGlueTcTextToCode": CodeXGlueTcTextToCodeImpl,
|
| 46 |
-
}
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
class CodeXGlueTcTextToCode(datasets.GeneratorBasedBuilder):
|
| 50 |
-
BUILDER_CONFIG_CLASS = datasets.BuilderConfig
|
| 51 |
-
BUILDER_CONFIGS = [
|
| 52 |
-
datasets.BuilderConfig(name=name, description=info["description"]) for name, info in DEFINITIONS.items()
|
| 53 |
-
]
|
| 54 |
-
|
| 55 |
-
def _info(self):
|
| 56 |
-
name = self.config.name
|
| 57 |
-
info = DEFINITIONS[name]
|
| 58 |
-
if info["class_name"] in CLASS_MAPPING:
|
| 59 |
-
self.child = CLASS_MAPPING[info["class_name"]](info)
|
| 60 |
-
else:
|
| 61 |
-
raise RuntimeError(f"Unknown python class for dataset configuration {name}")
|
| 62 |
-
ret = self.child._info()
|
| 63 |
-
return ret
|
| 64 |
-
|
| 65 |
-
def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
|
| 66 |
-
return self.child._split_generators(dl_manager=dl_manager)
|
| 67 |
-
|
| 68 |
-
def _generate_examples(self, split_name, file_paths):
|
| 69 |
-
return self.child._generate_examples(split_name, file_paths)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|