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