Datasets:
File size: 2,169 Bytes
5b91c70 68813ae 5b91c70 68813ae 5b91c70 1a7904f 5b91c70 1a7904f 5b91c70 f7a9211 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
"""MCoNaLa dataset."""
import json
import datasets
_CITATION = """\
@article{wang2022mconala,
title={MCoNaLa: A Benchmark for Code Generation from Multiple Natural Languages},
author={Zhiruo Wang, Grace Cuenca, Shuyan Zhou, Frank F. Xu, Graham Neubig},
journal={arXiv preprint arXiv:2203.08388},
year={2022}
}
"""
_DESCRIPTION = """\
MCoNaLa is a Multilingual Code/Natural Language Challenge dataset with
896 NL-Code pairs in three languages: Spanish, Japanese, and Russian.
"""
_HOMEPAGE = "https://github.com/zorazrw/multilingual-conala"
_URLs = {
"es": "es_test.json",
"ja": "ja_test.json",
"ru": "ru_test.json",
}
class MCoNaLa(datasets.GeneratorBasedBuilder):
"""MCoNaLa NL-to-Code dataset."""
VERSION = datasets.Version("1.0.0")
BUILDER_CONFIGS = [
datasets.BuilderConfig(
name=lang,
version=datasets.Version("1.0.0"),
description=_DESCRIPTION,
) for lang in _URLs.keys()
]
DEFAULT_CONFIG_NAME = "en"
def _info(self):
features = datasets.Features({"question_id": datasets.Value("int64"),
"intent": datasets.Value("string"),
"rewritten_intent": datasets.Value("string"),
"snippet": datasets.Value("string"),
})
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=features,
supervised_keys=None,
citation=_CITATION,
homepage=_HOMEPAGE)
def _split_generators(self, dl_manager):
"""Returns SplitGenerators."""
config_urls = _URLs[self.config.name]
data_dir = dl_manager.download_and_extract(config_urls)
return [
datasets.SplitGenerator(
name=datasets.Split.TEST,
gen_kwargs={"filepath": data_dir, "split": "train"},
),
]
def _generate_examples(self, filepath, split):
dataset = json.load(open(filepath, encoding="utf-8"))
for key, line in enumerate(dataset):
yield key, line |