Commit ·
deec917
1
Parent(s): a7da1a6
Create awesome-stuff.py
Browse files- awesome-stuff.py +61 -0
awesome-stuff.py
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import datasets
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
class AwesomeStuff(datasets.GeneratorBasedBuilder):
|
| 5 |
+
|
| 6 |
+
BUILDER_CONFIGS = [
|
| 7 |
+
datasets.BuilderConfig(name="first", version=VERSION, description="This part of my dataset covers a first domain"),
|
| 8 |
+
datasets.BuilderConfig(name="second", version=VERSION, description="This part of my dataset covers a second domain"),
|
| 9 |
+
]
|
| 10 |
+
|
| 11 |
+
def _info(self):
|
| 12 |
+
features = datasets.Features(
|
| 13 |
+
{
|
| 14 |
+
"number": datasets.Value("int"),
|
| 15 |
+
"string": datasets.Value("string"),
|
| 16 |
+
}
|
| 17 |
+
)
|
| 18 |
+
return datasets.DatasetInfo(
|
| 19 |
+
# This is the description that will appear on the datasets page.
|
| 20 |
+
description="_DESC",
|
| 21 |
+
# This defines the different columns of the dataset and their types
|
| 22 |
+
features=features, # Here we define them above because they are different between the two configurations
|
| 23 |
+
# If there's a common (input, target) tuple from the features, uncomment supervised_keys line below and
|
| 24 |
+
# specify them. They'll be used if as_supervised=True in builder.as_dataset.
|
| 25 |
+
# supervised_keys=("sentence", "label"),
|
| 26 |
+
# Homepage of the dataset for documentation
|
| 27 |
+
homepage="_HOMEPAGE",
|
| 28 |
+
# License for the dataset if available
|
| 29 |
+
license="_LICENSE",
|
| 30 |
+
# Citation for the dataset
|
| 31 |
+
citation="_CITATION",
|
| 32 |
+
)
|
| 33 |
+
|
| 34 |
+
def _split_generators(self, dl_manager):
|
| 35 |
+
return [
|
| 36 |
+
datasets.SplitGenerator(
|
| 37 |
+
name=datasets.Split.TRAIN,
|
| 38 |
+
# These kwargs will be passed to _generate_examples
|
| 39 |
+
gen_kwargs={
|
| 40 |
+
"split": "train",
|
| 41 |
+
},
|
| 42 |
+
),
|
| 43 |
+
datasets.SplitGenerator(
|
| 44 |
+
name=datasets.Split.TEST,
|
| 45 |
+
# These kwargs will be passed to _generate_examples
|
| 46 |
+
gen_kwargs={
|
| 47 |
+
"split": "test"
|
| 48 |
+
},
|
| 49 |
+
),
|
| 50 |
+
]
|
| 51 |
+
|
| 52 |
+
def _generate_examples(self, split):
|
| 53 |
+
if self.config.name == "first":
|
| 54 |
+
n_max = 10000 if split == "train" else 100
|
| 55 |
+
else:
|
| 56 |
+
n_max = 7000 if split == "train" else 200
|
| 57 |
+
for i in range(10000):
|
| 58 |
+
yield {
|
| 59 |
+
"number": i,
|
| 60 |
+
"string": f"{self.config.name}_{split}",
|
| 61 |
+
}
|