loubnabnl HF staff commited on
Commit
1f47868
1 Parent(s): 27b91a3

Upload odex.py

Browse files

This dataset script allows easy loading of the data subsets. For example you can now load the japanese subset with:
```python
from datasets import load_dataset

ds = load_dataset("neulab/odex", "ja")
````
By default (i.e `load_dataset("neulab/odex")`) loads the english subset.

Files changed (1) hide show
  1. odex.py +82 -0
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