Upload odex.py (#1)
Browse files- Upload odex.py (1f4786816c848bf633c69cc55b5c2ff0befebe39)
- Update README.md (c40a5ff8e66c4e45fea1d33f39f633669053b68c)
Co-authored-by: loubna ben allal <loubnabnl@users.noreply.huggingface.co>
README.md
CHANGED
@@ -16,6 +16,12 @@ __ODEX__ is an Open-Domain EXecution-based NL-to-Code generation data benchmark.
|
|
16 |
It contains 945 samples with a total of 1,707 human-written test cases, covering intents in four different natural languages -- 439 in English, 90 in Spanish, 164 in Japanese, and 252 in Russian.
|
17 |
|
18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
If you find our dataset useful, please cite the paper
|
21 |
|
|
|
16 |
It contains 945 samples with a total of 1,707 human-written test cases, covering intents in four different natural languages -- 439 in English, 90 in Spanish, 164 in Japanese, and 252 in Russian.
|
17 |
|
18 |
|
19 |
+
You can load the dataset by specifying a subset from *en, es, ja, ru* (by default the english subset *en* is loaded):
|
20 |
+
```python
|
21 |
+
from datasets import load_dataset
|
22 |
+
|
23 |
+
ds = load_dataset("neulab/odex", "ja", split="test")
|
24 |
+
```
|
25 |
|
26 |
If you find our dataset useful, please cite the paper
|
27 |
|
odex.py
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""Odex dataset."""
|
2 |
+
|
3 |
+
import json
|
4 |
+
import datasets
|
5 |
+
|
6 |
+
|
7 |
+
_CITATION = """\
|
8 |
+
@article{wang2022execution,
|
9 |
+
title={Execution-Based Evaluation for Open-Domain Code Generation},
|
10 |
+
author={Wang, Zhiruo and Zhou, Shuyan and Fried, Daniel and Neubig, Graham},
|
11 |
+
journal={arXiv preprint arXiv:2212.10481},
|
12 |
+
year={2022}
|
13 |
+
}
|
14 |
+
"""
|
15 |
+
|
16 |
+
_DESCRIPTION = """\
|
17 |
+
ODEX is an Open-Domain EXecution-based NL-to-Code generation data benchmark.
|
18 |
+
It contains 945 samples with a total of 1,707 human-written test cases,
|
19 |
+
covering intents in four different natural languages -- 439 in English, 90 in Spanish, 164 in Japanese, and 252 in Russian.
|
20 |
+
"""
|
21 |
+
|
22 |
+
_HOMEPAGE = "https://github.com/zorazrw/odex"
|
23 |
+
_URLs = {
|
24 |
+
"en": "en_test.jsonl",
|
25 |
+
"es": "es_test.jsonl",
|
26 |
+
"ja": "ja_test.jsonl",
|
27 |
+
"ru": "ru_test.jsonl",
|
28 |
+
}
|
29 |
+
|
30 |
+
class Odex(datasets.GeneratorBasedBuilder):
|
31 |
+
"""ODEX Code dataset."""
|
32 |
+
|
33 |
+
VERSION = datasets.Version("1.0.0")
|
34 |
+
|
35 |
+
|
36 |
+
BUILDER_CONFIGS = [
|
37 |
+
datasets.BuilderConfig(
|
38 |
+
name=lang,
|
39 |
+
version=datasets.Version("1.0.0"),
|
40 |
+
description=_DESCRIPTION,
|
41 |
+
) for lang in _URLs.keys()
|
42 |
+
]
|
43 |
+
|
44 |
+
DEFAULT_CONFIG_NAME = "en"
|
45 |
+
|
46 |
+
|
47 |
+
def _info(self):
|
48 |
+
features = datasets.Features({"task_id": datasets.Value("int64"),
|
49 |
+
"prompt": datasets.Value("string"),
|
50 |
+
"suffix": datasets.Value("string"),
|
51 |
+
"canonical_solution": datasets.Value("string"),
|
52 |
+
"test_start": datasets.Value("string"),
|
53 |
+
"test": datasets.Sequence(datasets.Value("string")),
|
54 |
+
"entry_point": datasets.Value("string"),
|
55 |
+
"intent": datasets.Value("string"),
|
56 |
+
"library": datasets.Sequence(datasets.Value("string")),
|
57 |
+
})
|
58 |
+
return datasets.DatasetInfo(
|
59 |
+
description=_DESCRIPTION,
|
60 |
+
features=features,
|
61 |
+
supervised_keys=None,
|
62 |
+
citation=_CITATION,
|
63 |
+
homepage=_HOMEPAGE)
|
64 |
+
|
65 |
+
def _split_generators(self, dl_manager):
|
66 |
+
"""Returns SplitGenerators."""
|
67 |
+
config_urls = _URLs[self.config.name]
|
68 |
+
data_dir = dl_manager.download_and_extract(config_urls)
|
69 |
+
return [
|
70 |
+
datasets.SplitGenerator(
|
71 |
+
name=datasets.Split.TEST,
|
72 |
+
gen_kwargs={"filepath": data_dir, "split": "train"},
|
73 |
+
),
|
74 |
+
]
|
75 |
+
|
76 |
+
|
77 |
+
def _generate_examples(self, filepath, split):
|
78 |
+
key = 0
|
79 |
+
for line in open(filepath, encoding="utf-8"):
|
80 |
+
line = json.loads(line)
|
81 |
+
yield key, line
|
82 |
+
key += 1
|