reformat and fix the generator
Browse files
zenodo.py
CHANGED
|
@@ -12,52 +12,12 @@ This dataset is for downloading a Zenodo dataset without extra packages.
|
|
| 12 |
"""
|
| 13 |
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
class NewDataset(datasets.GeneratorBasedBuilder):
|
| 18 |
"""This dataset downloads a zenodo dataset and returns its path."""
|
| 19 |
|
| 20 |
VERSION = datasets.Version("1.1.0")
|
| 21 |
|
| 22 |
-
# This is an example of a dataset with multiple configurations.
|
| 23 |
-
# If you don't want/need to define several sub-sets in your dataset,
|
| 24 |
-
# just remove the BUILDER_CONFIG_CLASS and the BUILDER_CONFIGS attributes.
|
| 25 |
-
|
| 26 |
-
# If you need to make complex sub-parts in the datasets with configurable options
|
| 27 |
-
# You can create your own builder configuration class to store attribute, inheriting from datasets.BuilderConfig
|
| 28 |
-
# BUILDER_CONFIG_CLASS = MyBuilderConfig
|
| 29 |
-
|
| 30 |
-
# You will be able to load one or the other configurations in the following list with
|
| 31 |
-
# data = datasets.load_dataset('my_dataset', 'first_domain')
|
| 32 |
-
# data = datasets.load_dataset('my_dataset', 'second_domain')
|
| 33 |
-
# BUILDER_CONFIGS = [
|
| 34 |
-
# datasets.BuilderConfig(name="first_domain", version=VERSION, description="This part of my dataset covers a first domain"),
|
| 35 |
-
# datasets.BuilderConfig(name="second_domain", version=VERSION, description="This part of my dataset covers a second domain"),
|
| 36 |
-
# ]
|
| 37 |
-
|
| 38 |
-
# DEFAULT_CONFIG_NAME = "first_domain" # It's not mandatory to have a default configuration. Just use one if it make sense.
|
| 39 |
-
|
| 40 |
def _info(self):
|
| 41 |
-
# TODO: This method specifies the datasets.DatasetInfo object which contains informations and typings for the dataset
|
| 42 |
-
# if self.config.name == "first_domain": # This is the name of the configuration selected in BUILDER_CONFIGS above
|
| 43 |
-
# features = datasets.Features(
|
| 44 |
-
# {
|
| 45 |
-
# "sentence": datasets.Value("string"),
|
| 46 |
-
# "option1": datasets.Value("string"),
|
| 47 |
-
# "answer": datasets.Value("string")
|
| 48 |
-
# # These are the features of your dataset like images, labels ...
|
| 49 |
-
# }
|
| 50 |
-
# )
|
| 51 |
-
# else: # This is an example to show how to have different features for "first_domain" and "second_domain"
|
| 52 |
-
# features = datasets.Features(
|
| 53 |
-
# {
|
| 54 |
-
# "sentence": datasets.Value("string"),
|
| 55 |
-
# "option2": datasets.Value("string"),
|
| 56 |
-
# "second_domain_answer": datasets.Value("string")
|
| 57 |
-
# # These are the features of your dataset like images, labels ...
|
| 58 |
-
# }
|
| 59 |
-
# )
|
| 60 |
-
|
| 61 |
features = datasets.Features(
|
| 62 |
{
|
| 63 |
"path": datasets.Value("string"),
|
|
@@ -65,28 +25,11 @@ class NewDataset(datasets.GeneratorBasedBuilder):
|
|
| 65 |
)
|
| 66 |
|
| 67 |
return datasets.DatasetInfo(
|
| 68 |
-
# This is the description that will appear on the datasets page.
|
| 69 |
description=_DESCRIPTION,
|
| 70 |
-
|
| 71 |
-
features=features, # Here we define them above because they are different between the two configurations
|
| 72 |
-
# If there's a common (input, target) tuple from the features, uncomment supervised_keys line below and
|
| 73 |
-
# specify them. They'll be used if as_supervised=True in builder.as_dataset.
|
| 74 |
-
# supervised_keys=("sentence", "label"),
|
| 75 |
-
# Homepage of the dataset for documentation
|
| 76 |
-
# homepage=_HOMEPAGE,
|
| 77 |
-
# License for the dataset if available
|
| 78 |
-
# license=_LICENSE,
|
| 79 |
-
# Citation for the dataset
|
| 80 |
-
# citation=_CITATION,
|
| 81 |
)
|
| 82 |
|
| 83 |
def _split_generators(self, dl_manager):
|
| 84 |
-
# TODO: This method is tasked with downloading/extracting the data and defining the splits depending on the configuration
|
| 85 |
-
# If several configurations are possible (listed in BUILDER_CONFIGS), the configuration selected by the user is in self.config.name
|
| 86 |
-
|
| 87 |
-
# dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
|
| 88 |
-
# It can accept any type or nested list/dict and will give back the same structure with the url replaced with path to local files.
|
| 89 |
-
# By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
|
| 90 |
zenodo_id = self.config.name.split("_")[0]
|
| 91 |
filename = self.config.name.split("_")[1]
|
| 92 |
|
|
@@ -102,10 +45,5 @@ class NewDataset(datasets.GeneratorBasedBuilder):
|
|
| 102 |
),
|
| 103 |
]
|
| 104 |
|
| 105 |
-
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
| 106 |
def _generate_examples(self, filepath):
|
| 107 |
-
|
| 108 |
-
# The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
|
| 109 |
-
|
| 110 |
-
yield "path", filepath
|
| 111 |
-
|
|
|
|
| 12 |
"""
|
| 13 |
|
| 14 |
|
|
|
|
|
|
|
| 15 |
class NewDataset(datasets.GeneratorBasedBuilder):
|
| 16 |
"""This dataset downloads a zenodo dataset and returns its path."""
|
| 17 |
|
| 18 |
VERSION = datasets.Version("1.1.0")
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
def _info(self):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
features = datasets.Features(
|
| 22 |
{
|
| 23 |
"path": datasets.Value("string"),
|
|
|
|
| 25 |
)
|
| 26 |
|
| 27 |
return datasets.DatasetInfo(
|
|
|
|
| 28 |
description=_DESCRIPTION,
|
| 29 |
+
features=features,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
)
|
| 31 |
|
| 32 |
def _split_generators(self, dl_manager):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
zenodo_id = self.config.name.split("_")[0]
|
| 34 |
filename = self.config.name.split("_")[1]
|
| 35 |
|
|
|
|
| 45 |
),
|
| 46 |
]
|
| 47 |
|
|
|
|
| 48 |
def _generate_examples(self, filepath):
|
| 49 |
+
yield 0, {"path": filepath}
|
|
|
|
|
|
|
|
|
|
|
|