Datasets:

Languages:
English
ArXiv:
Tags:
code
License:
gabeorlanski commited on
Commit
7843013
1 Parent(s): cc75a93

Upload bc-mbpp.py

Browse files
Files changed (1) hide show
  1. bc-mbpp.py +129 -0
bc-mbpp.py ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+
3
+ import datasets
4
+
5
+
6
+ _DESCRIPTION = """The MBPP dataset in BabelCode format."""
7
+
8
+ _URL = "https://raw.githubusercontent.com/google-research/babelcode/main/data/hf_datasets/mbpp.jsonl"
9
+
10
+ _LANGUAGES = {
11
+ "C++",
12
+ "CSharp",
13
+ "Dart",
14
+ "Go",
15
+ "Haskell",
16
+ "Java",
17
+ "Javascript",
18
+ "Julia",
19
+ "Kotlin",
20
+ "Lua",
21
+ "PHP",
22
+ "R",
23
+ "Rust",
24
+ "Scala",
25
+ "TypeScript",
26
+ }
27
+
28
+ _CITATION = """\
29
+ @article{orlanski2023measuring,
30
+ title={Measuring The Impact Of Programming Language Distribution},
31
+ author={Orlanski, Gabriel and Xiao, Kefan and Garcia, Xavier and Hui, Jeffrey and Howland, Joshua and Malmaud, Jonathan and Austin, Jacob and Singh, Rishah and Catasta, Michele},
32
+ journal={arXiv preprint arXiv:2302.01973},
33
+ year={2023}
34
+ }
35
+ @article{Austin2021ProgramSW,
36
+ title={Program Synthesis with Large Language Models},
37
+ author={Jacob Austin and Augustus Odena and Maxwell Nye and Maarten Bosma and Henryk Michalewski and David Dohan and Ellen Jiang and Carrie J. Cai and Michael Terry and Quoc V. Le and Charles Sutton},
38
+ journal={ArXiv},
39
+ year={2021},
40
+ volume={abs/2108.07732}
41
+ }"""
42
+
43
+ _HOMEPAGE = "https://github.com/google-research/babelcode"
44
+
45
+ _LICENSE = "CC-BY-4.0"
46
+
47
+ _VERSION = "1.0.0"
48
+
49
+ _KEYS_REMOVE = {
50
+ "header","test_list", "test_case_ids",
51
+ }
52
+
53
+ class BCMBPP(datasets.GeneratorBasedBuilder):
54
+ """BC-MBPP"""
55
+
56
+ VERSION = datasets.Version(_VERSION)
57
+
58
+ BUILDER_CONFIGS = [
59
+ datasets.BuilderConfig(
60
+ name="all",
61
+ version=datasets.Version(_VERSION),
62
+ description=_DESCRIPTION,
63
+ ),
64
+ ] + [
65
+ datasets.BuilderConfig(
66
+ name=lang,
67
+ version=datasets.Version(_VERSION),
68
+ description=_DESCRIPTION + f" Examples are only in {lang}.",
69
+ )
70
+ for lang in _LANGUAGES
71
+ ]
72
+
73
+ DEFAULT_CONFIG_NAME = "all"
74
+
75
+ def _info(self):
76
+ features = datasets.Features(
77
+ {
78
+ "qid": datasets.Value("string"),
79
+ "title": datasets.Value("string"),
80
+ "language": datasets.Value("string"),
81
+ "text":datasets.Value("string"),
82
+ "signature_with_docstring": datasets.Value("string"),
83
+ "signature": datasets.Value("string"),
84
+ "arguments": datasets.Sequence(datasets.Value("string")),
85
+ "entry_fn_name": datasets.Value("string"),
86
+ "entry_cls_name": datasets.Value("string"),
87
+ "test_code": datasets.Value("string"),
88
+ }
89
+ )
90
+ description = _DESCRIPTION
91
+ if self.config.name != 'all':
92
+ description = _DESCRIPTION + f" Examples are only in {self.config.name}."
93
+ return datasets.DatasetInfo(
94
+ description=description,
95
+ features=features,
96
+ supervised_keys=None,
97
+ homepage=_HOMEPAGE,
98
+ license=_LICENSE,
99
+ citation=_CITATION,
100
+ )
101
+
102
+ def _split_generators(self, dl_manager):
103
+ """Returns SplitGenerators."""
104
+ data_dir = dl_manager.download_and_extract(_URL)
105
+ return [
106
+ datasets.SplitGenerator(
107
+ name=datasets.Split.TEST,
108
+ gen_kwargs={"filepath": data_dir},
109
+ ),
110
+ ]
111
+
112
+ def _generate_examples(self, filepath):
113
+ """ Yields the examples from the dataset"""
114
+ with open(filepath, encoding='utf-8') as file:
115
+ id_ = 0
116
+ for l in file:
117
+ if not l.strip():
118
+ continue
119
+ d = json.loads(l)
120
+
121
+ if self.config.name != 'all' and d['language'] != self.config.name:
122
+ continue
123
+ for k in _KEYS_REMOVE:
124
+ d.pop(k)
125
+ yield id_, d
126
+ id_+=1
127
+
128
+
129
+