File size: 1,430 Bytes
c163af6 314cc95 a54a55b c163af6 314cc95 02f406b 314cc95 02f406b 1f4e257 9d88bff 0882a5c 86d38dc 9d88bff d8f1b83 9d88bff c2dec71 02f406b c2dec71 02f406b c2dec71 1f4e257 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
import json
import os
import datasets
class TestBConfig(datasets.BuilderConfig):
"""BuilderConfig for SuperGLUE."""
def __init__(self, data_url, **kwargs):
super().__init__(version=datasets.Version("1.0.2"), **kwargs)
self.data_url = data_url
class TestB(datasets.GeneratorBasedBuilder):
"""The SuperGLUE benchmark."""
BUILDER_CONFIGS = [
TestBConfig(
name="data1",
data_url="data1",
),
TestBConfig(
name="data2",
data_url="data2",
)]
def _info(self):
return datasets.DatasetInfo(
description='desc'
)
def _split_generators(self, dl_manager):
dl_dir = dl_manager.download_and_extract(self.config.data_url+'/test.json') or ""
task_name = _get_task_name_from_data_url(self.config.data_url)
dl_dir = os.path.join(dl_dir, task_name)
print('dl_dir',dl_dir)
return [
datasets.SplitGenerator(
name=datasets.Split.TRAIN,
gen_kwargs={
"data_file": os.path.join(dl_dir "test.json"),
"split": datasets.Split.TRAIN,
},
)
]
def _generate_examples(self, data_file, split):
with open(data_file, encoding="utf-8") as f:
for line in f:
row = json.loads(line)
yield row |