Datasets:
BNNT
/

Modalities:
Text
Formats:
json
Libraries:
Datasets
Dask
License:
visualjoyce commited on
Commit
8d9037d
1 Parent(s): ca03664

Add zh, en, xl

Browse files
Files changed (4) hide show
  1. en.json +0 -0
  2. ipquiz.py +149 -0
  3. xl.json +0 -0
  4. zh.json +0 -0
en.json ADDED
The diff for this file is too large to render. See raw diff
 
ipquiz.py ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ # TODO: Address all TODOs and remove all explanatory comments
15
+ """TODO: Add a description here."""
16
+
17
+
18
+ import csv
19
+ import json
20
+ import os
21
+
22
+ import datasets
23
+
24
+
25
+ # TODO: Add BibTeX citation
26
+ # Find for instance the citation on arxiv or on the dataset repo/website
27
+ _CITATION = """\
28
+ @InProceedings{huggingface:dataset,
29
+ title = {A great new dataset},
30
+ author={huggingface, Inc.
31
+ },
32
+ year={2020}
33
+ }
34
+ """
35
+
36
+ # TODO: Add description of the dataset here
37
+ # You can copy an official description
38
+ _DESCRIPTION = """\
39
+ This new dataset is designed to solve this great NLP task and is crafted with a lot of care.
40
+ """
41
+
42
+ # TODO: Add a link to an official homepage for the dataset here
43
+ _HOMEPAGE = ""
44
+
45
+ # TODO: Add the licence for the dataset here if you can find it
46
+ _LICENSE = ""
47
+
48
+
49
+ # TODO: Name of the dataset usually matches the script name with CamelCase instead of snake_case
50
+ class IPQuizDataset(datasets.GeneratorBasedBuilder):
51
+ """TODO: Short description of my dataset."""
52
+
53
+ VERSION = datasets.Version("1.1.0")
54
+
55
+ # This is an example of a dataset with multiple configurations.
56
+ # If you don't want/need to define several sub-sets in your dataset,
57
+ # just remove the BUILDER_CONFIG_CLASS and the BUILDER_CONFIGS attributes.
58
+
59
+ # If you need to make complex sub-parts in the datasets with configurable options
60
+ # You can create your own builder configuration class to store attribute, inheriting from datasets.BuilderConfig
61
+ # BUILDER_CONFIG_CLASS = MyBuilderConfig
62
+
63
+ # You will be able to load one or the other configurations in the following list with
64
+ # data = datasets.load_dataset('my_dataset', 'first_domain')
65
+ # data = datasets.load_dataset('my_dataset', 'second_domain')
66
+ BUILDER_CONFIGS = [
67
+ datasets.BuilderConfig(name="zh", version=VERSION, description="This part of my dataset covers a first domain"),
68
+ datasets.BuilderConfig(name="en", version=VERSION, description="This part of my dataset covers a first domain"),
69
+ datasets.BuilderConfig(name="xl", version=VERSION, description="This part of my dataset covers a second domain"),
70
+ ]
71
+
72
+ DEFAULT_CONFIG_NAME = "zh" # It's not mandatory to have a default configuration. Just use one if it make sense.
73
+
74
+ def _info(self):
75
+ # TODO: This method specifies the datasets.DatasetInfo object which contains informations and typings for the dataset
76
+ features = datasets.Features(
77
+ {
78
+ "language": datasets.Value("language"),
79
+ "problem": datasets.Value("string"),
80
+ "candidates": datasets.Value("dict"),
81
+ "answer": datasets.Value("string")
82
+ # These are the features of your dataset like images, labels ...
83
+ }
84
+ )
85
+ return datasets.DatasetInfo(
86
+ # This is the description that will appear on the datasets page.
87
+ description=_DESCRIPTION,
88
+ # This defines the different columns of the dataset and their types
89
+ features=features, # Here we define them above because they are different between the two configurations
90
+ # If there's a common (input, target) tuple from the features, uncomment supervised_keys line below and
91
+ # specify them. They'll be used if as_supervised=True in builder.as_dataset.
92
+ # supervised_keys=("sentence", "label"),
93
+ # Homepage of the dataset for documentation
94
+ homepage=_HOMEPAGE,
95
+ # License for the dataset if available
96
+ license=_LICENSE,
97
+ # Citation for the dataset
98
+ citation=_CITATION,
99
+ )
100
+
101
+ def _split_generators(self, dl_manager):
102
+ # TODO: This method is tasked with downloading/extracting the data and defining the splits depending on the configuration
103
+ # If several configurations are possible (listed in BUILDER_CONFIGS), the configuration selected by the user is in self.config.name
104
+
105
+ # dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
106
+ # 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.
107
+ # By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
108
+ data_dir = dl_manager.download_and_extract(urls)
109
+ return [
110
+ datasets.SplitGenerator(
111
+ name=datasets.Split.TRAIN,
112
+ # These kwargs will be passed to _generate_examples
113
+ gen_kwargs={
114
+ "filepath": os.path.join(data_dir, "train.jsonl"),
115
+ "split": "train",
116
+ },
117
+ ),
118
+ datasets.SplitGenerator(
119
+ name=datasets.Split.VALIDATION,
120
+ # These kwargs will be passed to _generate_examples
121
+ gen_kwargs={
122
+ "filepath": os.path.join(data_dir, "dev.jsonl"),
123
+ "split": "dev",
124
+ },
125
+ ),
126
+ datasets.SplitGenerator(
127
+ name=datasets.Split.TEST,
128
+ # These kwargs will be passed to _generate_examples
129
+ gen_kwargs={
130
+ "filepath": os.path.join(data_dir, "{self.config.name}.jsonl"),
131
+ "split": "test"
132
+ },
133
+ ),
134
+ ]
135
+
136
+ # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
137
+ def _generate_examples(self, filepath, split):
138
+ # TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
139
+ # The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
140
+ with open(filepath, encoding="utf-8") as f:
141
+ data = json.load(f)
142
+ for key, row in enumerate(data):
143
+ # Yields examples as (key, example) tuples
144
+ yield key, {
145
+ "language": row["language"],
146
+ "problem": row["problem"],
147
+ "candidates": row["candidates"],
148
+ "answer": row['answer'],
149
+ }
xl.json ADDED
The diff for this file is too large to render. See raw diff
 
zh.json ADDED
The diff for this file is too large to render. See raw diff