JeremyAlain commited on
Commit
af33748
1 Parent(s): f1c9d6f

loading script created

Browse files
data/dataset_infos.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"data": {"description": "", "citation": "", "homepage": "", "license": "", "features": {"task": {"dtype": "string", "id": null, "_type": "Value"}, "input": {"dtype": "string", "id": null, "_type": "Value"}, "output": {"dtype": "string", "id": null, "_type": "Value"}, "options": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "pageTitle": {"dtype": "string", "id": null, "_type": "Value"}, "title": {"dtype": "string", "id": null, "_type": "Value"}, "outputColName": {"dtype": "string", "id": null, "_type": "Value"}, "url": {"dtype": "string", "id": null, "_type": "Value"}, "wdcFile": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "json", "config_name": "data", "version": {"version_str": "0.0.0", "description": null, "major": 0, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 31800, "num_examples": 600, "dataset_name": "json"}}, "download_checksums": {"/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/0/file_0.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/0/file_1.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/0/file_10.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/0/file_11.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/0/file_12.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/0/file_13.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/0/file_14.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/0/file_15.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/0/file_16.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/0/file_17.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/0/file_18.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/0/file_19.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/0/file_2.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/0/file_3.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/0/file_4.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/0/file_5.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/0/file_6.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/0/file_7.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/0/file_8.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/0/file_9.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/1/file_0.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/1/file_1.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/1/file_10.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/1/file_11.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/1/file_12.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/1/file_13.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/1/file_14.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/1/file_15.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/1/file_16.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/1/file_17.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/1/file_18.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/1/file_19.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/1/file_2.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/1/file_3.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/1/file_4.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/1/file_5.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/1/file_6.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/1/file_7.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/1/file_8.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/1/file_9.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/2/file_0.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/2/file_1.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/2/file_10.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/2/file_11.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/2/file_12.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/2/file_13.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/2/file_14.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/2/file_15.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/2/file_16.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/2/file_17.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/2/file_18.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/2/file_19.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/2/file_2.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/2/file_3.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/2/file_4.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/2/file_5.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/2/file_6.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/2/file_7.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/2/file_8.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}, "/Users/jeremyscheurer/Code/fewshot_pretraining/fewshot-pretrainin-repo/data/2/file_9.jsonl": {"num_bytes": 1289, "checksum": "5deba816488c07f199593deb6d7a8cf0f37982df2d5218676f3b5c0d66abbe43"}}, "download_size": 77340, "post_processing_size": null, "dataset_size": 31800, "size_in_bytes": 109140}}
fewshot_pretraining_loading_script.py ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ """This loads the fewshot-pretraining dataset."""
15
+
16
+ import json
17
+ import os
18
+ import pandas as pd
19
+
20
+ import datasets
21
+
22
+
23
+ # TODO: Add BibTeX citation
24
+ # Find for instance the citation on arxiv or on the dataset repo/website
25
+ _CITATION = """\
26
+ @InProceedings{huggingface:dataset,
27
+ title = {A great new dataset},
28
+ author={huggingface, Inc.
29
+ },
30
+ year={2020}
31
+ }
32
+ """
33
+
34
+ # You can copy an official description
35
+ _DESCRIPTION = """\
36
+ The Fewshot Table dataset consists of tables that naturally occur on the web, that are formatted as few-shot tasks for fine-tuning language models to improve their few-shot performance. The dataset consists of approximately 413K tables that are extracted from the WDC Web Table Corpora 2015, which is released under the Apache-2.0 license. The WDC Web Table Corpora "contains vast amounts of HTML tables. [...] The Web Data Commons project extracts relational Web tables from the Common Crawl, the largest and most up-to-date Web corpus that is currently available to the public."
37
+ """
38
+
39
+ # TODO: Add a link to an official homepage for the dataset here
40
+ _HOMEPAGE = ""
41
+
42
+ _LICENSE = "Apache 2.0"
43
+
44
+ # The HuggingFace Datasets library doesn't host the datasets but only points to the original files.
45
+ # This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
46
+ _URLS = {
47
+ "data_1": "https://huggingface.co/datasets/JeremyAlain/fewshot-ptretraining/data/1",
48
+ "data_2": "https://huggingface.co/datasets/JeremyAlain/fewshot-ptretraining/data/2",
49
+ "data_3": "https://huggingface.co/datasets/JeremyAlain/fewshot-ptretraining/data/3",
50
+
51
+ }
52
+
53
+
54
+ class FewshotPretraining(datasets.GeneratorBasedBuilder):
55
+ """The Fewshot Table dataset consists of tables that naturally occur on the web, that are formatted as few-shot tasks for fine-tuning language models to improve their few-shot performance. The dataset consists of approximately 413K tables that are extracted from the WDC Web Table Corpora 2015, which is released under the Apache-2.0 license. The WDC Web Table Corpora "contains vast amounts of HTML tables. [...] The Web Data Commons project extracts relational Web tables from the Common Crawl, the largest and most up-to-date Web corpus that is currently available to the public."
56
+ """
57
+
58
+ VERSION = datasets.Version("1.1.0")
59
+
60
+ # This is an example of a dataset with multiple configurations.
61
+ # If you don't want/need to define several sub-sets in your dataset,
62
+ # just remove the BUILDER_CONFIG_CLASS and the BUILDER_CONFIGS attributes.
63
+
64
+ # You will be able to load one or the other configurations in the following list with
65
+ # data = datasets.load_dataset('my_dataset', '1')
66
+ # data = datasets.load_dataset('my_dataset', '2')
67
+ BUILDER_CONFIGS = [
68
+ datasets.BuilderConfig(name="data_1", version=VERSION, description="This part of my dataset covers data_1"),
69
+ datasets.BuilderConfig(name="data_2", version=VERSION, description="This part of my dataset covers data_2"),
70
+ datasets.BuilderConfig(name="data_3", version=VERSION, description="This part of my dataset covers data_3"),
71
+ ]
72
+
73
+ DEFAULT_CONFIG_NAME = "data_1" # It's not mandatory to have a default configuration. Just use one if it make sense.
74
+
75
+ def _info(self):
76
+ features = datasets.Features(
77
+ {
78
+
79
+ "task": datasets.Value("string"),
80
+ "input": datasets.Value("string"),
81
+ "output": datasets.Value("string"),
82
+ "options": datasets.Sequence([datasets.Value("string")]),
83
+ "pageTitle": datasets.Value("string"),
84
+ "outputColName": datasets.Value("string"),
85
+ "url": datasets.Value("string"),
86
+ "wdcFile": datasets.Value("string")
87
+ }
88
+ )
89
+ return datasets.DatasetInfo(
90
+ # This is the description that will appear on the datasets page.
91
+ description=_DESCRIPTION,
92
+ # This defines the different columns of the dataset and their types
93
+ features=features, # Here we define them above because they are different between the two configurations
94
+ # If there's a common (input, target) tuple from the features, uncomment supervised_keys line below and
95
+ # specify them. They'll be used if as_supervised=True in builder.as_dataset.
96
+ # supervised_keys=("sentence", "label"),
97
+ # Homepage of the dataset for documentation
98
+ # TODO ACTIVATE IF WE HAVE HOMEPAGE homepage=_HOMEPAGE,
99
+ # License for the dataset if available
100
+ license=_LICENSE,
101
+ # Citation for the dataset
102
+ citation=_CITATION,
103
+ )
104
+
105
+ def _split_generators(self, dl_manager):
106
+ # TODO: This method is tasked with downloading/extracting the data and defining the splits depending on the configuration
107
+ # If several configurations are possible (listed in BUILDER_CONFIGS), the configuration selected by the user is in self.config.name
108
+
109
+ # dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
110
+ # 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.
111
+ # By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
112
+ urls = _URLS[self.config.name]
113
+ data_dir = dl_manager.download_and_extract(urls)
114
+ return datasets.SplitGenerator(
115
+ name=datasets.Split.TRAIN,
116
+ # These kwargs will be passed to _generate_examples
117
+ gen_kwargs={
118
+ "folder_path": data_dir,
119
+ "split": "train",
120
+ },
121
+ )
122
+
123
+
124
+ # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
125
+ def _generate_examples(self, folder_path, split):
126
+ # The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
127
+ for filepath in os.listdir(folder_path):
128
+ with open(filepath, encoding="utf-8") as f:
129
+ data = pd.read_json(filepath, orient="records", lines=True)
130
+ for i in range(data.shape[0]):
131
+ row = data.iloc[i]
132
+ # Yields examples as (key, example) tuples
133
+ key = row["task"] + "_i"
134
+ yield key, {
135
+ "task": data["task"],
136
+ "input": data["input"],
137
+ "output": data["output"],
138
+ "options": data["options"],
139
+ "pageTitle": data["pageTitle"],
140
+ "outputColName": data["outputColName"],
141
+ "url": data["url"],
142
+ "wdcFile": data["wdcFile"],
143
+ }