gabeorlanski
commited on
Commit
•
a7c1049
1
Parent(s):
b09d77d
Update bc-mbpp.py
Browse files- bc-mbpp.py +28 -2
bc-mbpp.py
CHANGED
@@ -103,16 +103,38 @@ class BCMBPP(datasets.GeneratorBasedBuilder):
|
|
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
|
@@ -120,6 +142,10 @@ class BCMBPP(datasets.GeneratorBasedBuilder):
|
|
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
|
|
|
103 |
"""Returns SplitGenerators."""
|
104 |
data_dir = dl_manager.download_and_extract(_URL)
|
105 |
return [
|
106 |
+
datasets.SplitGenerator(
|
107 |
+
name=datasets.Split.TRAIN,
|
108 |
+
gen_kwargs={"filepath": data_dir, "split": "train"},
|
109 |
+
),
|
110 |
datasets.SplitGenerator(
|
111 |
name=datasets.Split.TEST,
|
112 |
+
gen_kwargs={"filepath": data_dir, "split": "test"},
|
113 |
+
),
|
114 |
+
datasets.SplitGenerator(
|
115 |
+
name=datasets.Split.VALIDATION,
|
116 |
+
gen_kwargs={"filepath": data_dir, "split": "validation"},
|
117 |
+
),
|
118 |
+
datasets.SplitGenerator(
|
119 |
+
name=datasets.Split("prompt"),
|
120 |
+
gen_kwargs={"filepath": data_dir, "split": "prompt"},
|
121 |
),
|
122 |
]
|
123 |
|
124 |
+
def _generate_examples(self, filepath, split):
|
125 |
""" Yields the examples from the dataset"""
|
126 |
with open(filepath, encoding='utf-8') as file:
|
127 |
id_ = 0
|
128 |
+
idx_range = None
|
129 |
+
if split == 'test':
|
130 |
+
idx_range=(11,510)
|
131 |
+
elif split == "train":
|
132 |
+
idx_range=(601,974)
|
133 |
+
elif split == "validation":
|
134 |
+
idx_range=(511, 600)
|
135 |
+
else:
|
136 |
+
idx_range=(1,10)
|
137 |
+
|
138 |
for l in file:
|
139 |
if not l.strip():
|
140 |
continue
|
|
|
142 |
|
143 |
if self.config.name != 'all' and d['language'] != self.config.name:
|
144 |
continue
|
145 |
+
|
146 |
+
idx = int(d['title'].split('/')[-1])
|
147 |
+
if not (idx_range[0] <= idx <= idx_range[1]):
|
148 |
+
continue
|
149 |
for k in _KEYS_REMOVE:
|
150 |
d.pop(k)
|
151 |
yield id_, d
|