File size: 2,316 Bytes
deec917 a980504 deec917 bc5eca6 deec917 7905f93 6687360 deec917 | 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 50 51 52 53 54 55 56 57 58 59 60 61 62 | import datasets
class AwesomeStuff(datasets.GeneratorBasedBuilder):
BUILDER_CONFIGS = [
datasets.BuilderConfig(name="first", description="This part of my dataset covers a first domain"),
datasets.BuilderConfig(name="second", description="This part of my dataset covers a second domain"),
]
def _info(self):
features = datasets.Features(
{
"number": datasets.Value("int16"),
"string": datasets.Value("string"),
}
)
return datasets.DatasetInfo(
# This is the description that will appear on the datasets page.
description="_DESC",
# This defines the different columns of the dataset and their types
features=features, # Here we define them above because they are different between the two configurations
# If there's a common (input, target) tuple from the features, uncomment supervised_keys line below and
# specify them. They'll be used if as_supervised=True in builder.as_dataset.
# supervised_keys=("sentence", "label"),
# Homepage of the dataset for documentation
homepage="_HOMEPAGE",
# License for the dataset if available
license="_LICENSE",
# Citation for the dataset
citation="_CITATION",
)
def _split_generators(self, dl_manager):
return [
datasets.SplitGenerator(
name=datasets.Split.TRAIN,
# These kwargs will be passed to _generate_examples
gen_kwargs={
"split": "train",
},
),
datasets.SplitGenerator(
name=datasets.Split.TEST,
# These kwargs will be passed to _generate_examples
gen_kwargs={
"split": "test"
},
),
]
def _generate_examples(self, split):
if self.config.name == "first":
n_max = 10000 if split == "train" else 100
else:
n_max = 7000 if split == "train" else 200
for i in range(n_max):
yield i, {
"number": i,
"string": f"{self.config.name}_{split}",
}
|