|
import json |
|
import os |
|
|
|
import datasets |
|
|
|
class TestBConfig(datasets.BuilderConfig): |
|
"""BuilderConfig for SuperGLUE.""" |
|
|
|
def __init__(self, data_url, **kwargs): |
|
"""BuilderConfig for SuperGLUE. |
|
|
|
Args: |
|
features: *list[string]*, list of the features that will appear in the |
|
feature dict. Should not include "label". |
|
data_url: *string*, url to download the zip file from. |
|
citation: *string*, citation for the data set. |
|
url: *string*, url for information about the data set. |
|
label_classes: *list[string]*, the list of classes for the label if the |
|
label is present as a string. Non-string labels will be cast to either |
|
'False' or 'True'. |
|
**kwargs: keyword arguments forwarded to super. |
|
""" |
|
|
|
|
|
|
|
|
|
|
|
|
|
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): |
|
features = {feature: datasets.Value("string") for feature in self.config.features} |
|
|
|
return datasets.DatasetInfo( |
|
description='desc', |
|
features=datasets.Features(features), |
|
) |
|
|
|
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 |