Datasets:
qanta

Languages: English
Multilinguality: monolingual
Size Categories: 100K<n<1M
Language Creators: found
Annotations Creators: machine-generated
Source Datasets: original
License: unknown
system
HF staff
commited on
Commit
19bfe3d
0 Parent(s):

Update files from the datasets library (from 1.0.0)

Browse files

Release notes: https://github.com/huggingface/datasets/releases/tag/1.0.0

.gitattributes ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bin.* filter=lfs diff=lfs merge=lfs -text
5
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.model filter=lfs diff=lfs merge=lfs -text
12
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
13
+ *.onnx filter=lfs diff=lfs merge=lfs -text
14
+ *.ot filter=lfs diff=lfs merge=lfs -text
15
+ *.parquet filter=lfs diff=lfs merge=lfs -text
16
+ *.pb filter=lfs diff=lfs merge=lfs -text
17
+ *.pt filter=lfs diff=lfs merge=lfs -text
18
+ *.pth filter=lfs diff=lfs merge=lfs -text
19
+ *.rar filter=lfs diff=lfs merge=lfs -text
20
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
21
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
22
+ *.tflite filter=lfs diff=lfs merge=lfs -text
23
+ *.tgz filter=lfs diff=lfs merge=lfs -text
24
+ *.xz filter=lfs diff=lfs merge=lfs -text
25
+ *.zip filter=lfs diff=lfs merge=lfs -text
26
+ *.zstandard filter=lfs diff=lfs merge=lfs -text
27
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
dataset_infos.json ADDED
@@ -0,0 +1 @@
 
1
+ {"mode=first,char_skip=25": {"description": "\nThe Qanta dataset is a question answering dataset based on the academic trivia game Quizbowl.\n", "citation": "\n@article{Rodriguez2019QuizbowlTC,\n title={Quizbowl: The Case for Incremental Question Answering},\n author={Pedro Rodriguez and Shi Feng and Mohit Iyyer and He He and Jordan L. Boyd-Graber},\n journal={ArXiv},\n year={2019},\n volume={abs/1904.04792}\n}\n", "homepage": "http://www.qanta.org/", "license": "", "features": {"id": {"dtype": "string", "id": null, "_type": "Value"}, "qanta_id": {"dtype": "int32", "id": null, "_type": "Value"}, "proto_id": {"dtype": "string", "id": null, "_type": "Value"}, "qdb_id": {"dtype": "int32", "id": null, "_type": "Value"}, "dataset": {"dtype": "string", "id": null, "_type": "Value"}, "text": {"dtype": "string", "id": null, "_type": "Value"}, "full_question": {"dtype": "string", "id": null, "_type": "Value"}, "first_sentence": {"dtype": "string", "id": null, "_type": "Value"}, "char_idx": {"dtype": "int32", "id": null, "_type": "Value"}, "sentence_idx": {"dtype": "int32", "id": null, "_type": "Value"}, "tokenizations": {"feature": {"feature": {"dtype": "int32", "id": null, "_type": "Value"}, "length": 2, "id": null, "_type": "Sequence"}, "length": -1, "id": null, "_type": "Sequence"}, "answer": {"dtype": "string", "id": null, "_type": "Value"}, "page": {"dtype": "string", "id": null, "_type": "Value"}, "raw_answer": {"dtype": "string", "id": null, "_type": "Value"}, "fold": {"dtype": "string", "id": null, "_type": "Value"}, "gameplay": {"dtype": "bool", "id": null, "_type": "Value"}, "category": {"dtype": "string", "id": null, "_type": "Value"}, "subcategory": {"dtype": "string", "id": null, "_type": "Value"}, "tournament": {"dtype": "string", "id": null, "_type": "Value"}, "difficulty": {"dtype": "string", "id": null, "_type": "Value"}, "year": {"dtype": "int32", "id": null, "_type": "Value"}}, "supervised_keys": null, "builder_name": "qanta", "config_name": "mode=first,char_skip=25", "version": {"version_str": "2018.04.18", "description": null, "datasets_version_to_prepare": null, "major": 2018, "minor": 4, "patch": 18}, "splits": {"adversarial": {"name": "adversarial", "num_bytes": 1258844, "num_examples": 1145, "dataset_name": "qanta"}, "buzzdev": {"name": "buzzdev", "num_bytes": 1553636, "num_examples": 1161, "dataset_name": "qanta"}, "buzztest": {"name": "buzztest", "num_bytes": 2653425, "num_examples": 1953, "dataset_name": "qanta"}, "buzztrain": {"name": "buzztrain", "num_bytes": 19699736, "num_examples": 16706, "dataset_name": "qanta"}, "guessdev": {"name": "guessdev", "num_bytes": 1414882, "num_examples": 1055, "dataset_name": "qanta"}, "guesstest": {"name": "guesstest", "num_bytes": 2997123, "num_examples": 2151, "dataset_name": "qanta"}, "guesstrain": {"name": "guesstrain", "num_bytes": 117599750, "num_examples": 96221, "dataset_name": "qanta"}}, "download_checksums": {"https://s3-us-west-2.amazonaws.com/pinafore-us-west-2/qanta-jmlr-datasets/qanta.mapped.2018.04.18.json": {"num_bytes": 169001564, "checksum": "5f2f429724e13df1d4b216dba5549dac597fbaf884ed0c3e01f90ee72cb2753a"}, "https://s3-us-west-2.amazonaws.com/pinafore-us-west-2/trick-tacl-datasets/qanta.tacl-trick.json": {"num_bytes": 1753354, "checksum": "73535d6493d63bad48cd61031911faf77efb584976475185d8aca5a124d1822b"}}, "download_size": 170754918, "dataset_size": 147177396, "size_in_bytes": 317932314}}
dummy/mode=first,char_skip=25/2018.4.18/dummy_data.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:eb32bbb897f87b3e6541f97990d5418e6efaca1594102d05b917ef45187e6629
3
+ size 2117
dummy/mode=full,char_skip=25/2018.4.18/dummy_data.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:eb32bbb897f87b3e6541f97990d5418e6efaca1594102d05b917ef45187e6629
3
+ size 2117
dummy/mode=runs,char_skip=25/2018.4.18/dummy_data.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:eb32bbb897f87b3e6541f97990d5418e6efaca1594102d05b917ef45187e6629
3
+ size 2117
dummy/mode=sentences,char_skip=25/2018.4.18/dummy_data.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:eb32bbb897f87b3e6541f97990d5418e6efaca1594102d05b917ef45187e6629
3
+ size 2117
qanta.py ADDED
@@ -0,0 +1,290 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """qanta dataset."""
2
+
3
+ from __future__ import absolute_import, division, print_function
4
+
5
+ import json
6
+ from typing import List, Tuple
7
+
8
+ import datasets
9
+
10
+
11
+ _CITATION = """
12
+ @article{Rodriguez2019QuizbowlTC,
13
+ title={Quizbowl: The Case for Incremental Question Answering},
14
+ author={Pedro Rodriguez and Shi Feng and Mohit Iyyer and He He and Jordan L. Boyd-Graber},
15
+ journal={ArXiv},
16
+ year={2019},
17
+ volume={abs/1904.04792}
18
+ }
19
+ """
20
+
21
+ _DESCRIPTION = """
22
+ The Qanta dataset is a question answering dataset based on the academic trivia game Quizbowl.
23
+ """
24
+
25
+
26
+ _QANTA_URL = "https://s3-us-west-2.amazonaws.com/pinafore-us-west-2/qanta-jmlr-datasets/qanta.mapped.2018.04.18.json"
27
+ _TRICK_URL = "https://s3-us-west-2.amazonaws.com/pinafore-us-west-2/trick-tacl-datasets/qanta.tacl-trick.json"
28
+ _VERSION = datasets.Version("2018.04.18")
29
+ _FIRST = "first"
30
+ _FULL = "full"
31
+ _SENTENCES = "sentences"
32
+ _RUNS = "runs"
33
+ # Order matters, the first one is default
34
+ _MODES = [_FULL, _FIRST, _SENTENCES, _RUNS]
35
+ _DEFAULT_CHAR_SKIP = 25
36
+
37
+
38
+ class QantaConfig(datasets.BuilderConfig):
39
+ """BuilderConfig for Qanta."""
40
+
41
+ def __init__(self, mode: str, char_skip: int, **kwargs):
42
+ super(QantaConfig, self).__init__(version=_VERSION, **kwargs)
43
+ self.mode = mode
44
+ self.char_skip = char_skip
45
+
46
+
47
+ def create_char_runs(text: str, char_skip: int) -> List[Tuple[str, int]]:
48
+ """
49
+ Returns runs of the question based on skipping char_skip characters at a time. Also returns the indices used
50
+ q: name this first united states president.
51
+ runs with char_skip=10:
52
+ ['name this ',
53
+ 'name this first unit',
54
+ 'name this first united state p',
55
+ 'name this first united state president.']
56
+ :param char_skip: Number of characters to skip each time
57
+ """
58
+ char_indices = list(range(char_skip, len(text) + char_skip, char_skip))
59
+ return [(text[:idx], idx) for idx in char_indices]
60
+
61
+
62
+ def with_default(key, lookup, default):
63
+ if key in lookup:
64
+ value = lookup[key]
65
+ if value is None:
66
+ return default
67
+ else:
68
+ return value
69
+ else:
70
+ return default
71
+
72
+
73
+ def question_to_examples(question, mode: str, char_skip: int):
74
+ features = {
75
+ "qanta_id": question["qanta_id"],
76
+ "proto_id": with_default("proto_id", question, ""),
77
+ "qdb_id": with_default("qdb_id", question, -1),
78
+ # We refer to the actual answer as page, but this
79
+ # may be misleading externally, so rename here to
80
+ # be clearer
81
+ "page": question["page"],
82
+ "answer": question["page"],
83
+ "raw_answer": question["answer"],
84
+ "dataset": with_default("dataset", question, ""),
85
+ "full_question": question["text"],
86
+ "first_sentence": question["first_sentence"],
87
+ "tokenizations": question["tokenizations"],
88
+ "fold": question["fold"],
89
+ "gameplay": question["gameplay"],
90
+ "category": with_default("category", question, ""),
91
+ "subcategory": with_default("subcategory", question, ""),
92
+ "tournament": question["tournament"],
93
+ "difficulty": with_default("difficulty", question, ""),
94
+ "year": question["year"],
95
+ "char_idx": -1,
96
+ "sentence_idx": -1,
97
+ }
98
+ if mode == _FULL:
99
+ yield {
100
+ "text": question["text"],
101
+ "id": str(question["qanta_id"]) + "-full",
102
+ **features,
103
+ }
104
+ elif mode == _FIRST:
105
+ yield {
106
+ "text": question["first_sentence"],
107
+ "id": str(question["qanta_id"]) + "-first",
108
+ **features,
109
+ }
110
+ elif mode == _RUNS:
111
+ text = question["text"]
112
+ for text_run, char_idx in create_char_runs(text, char_skip):
113
+ yield {
114
+ "text": text_run,
115
+ "char_idx": char_idx,
116
+ "id": str(question["qanta_id"]) + "-char-" + str(char_idx),
117
+ **features,
118
+ }
119
+ elif mode == _SENTENCES:
120
+ for sentence_idx, (start, end) in enumerate(question["tokenizations"]):
121
+ sentence = question["text"][start:end]
122
+ yield {
123
+ "text": sentence,
124
+ "sentence_idx": sentence_idx,
125
+ "id": str(question["qanta_id"]) + "-sentence-" + str(sentence_idx),
126
+ **features,
127
+ }
128
+ else:
129
+ raise ValueError(f"Invalid mode: {mode}")
130
+
131
+
132
+ _FEATURES = {
133
+ # Generated ID based modes set, unique
134
+ "id": datasets.Value("string"),
135
+ # Dataset defined IDs
136
+ "qanta_id": datasets.Value("int32"),
137
+ "proto_id": datasets.Value("string"),
138
+ "qdb_id": datasets.Value("int32"),
139
+ "dataset": datasets.Value("string"),
140
+ # Inputs
141
+ "text": datasets.Value("string"),
142
+ "full_question": datasets.Value("string"),
143
+ "first_sentence": datasets.Value("string"),
144
+ "char_idx": datasets.Value("int32"),
145
+ "sentence_idx": datasets.Value("int32"),
146
+ # Character indices of sentences: List[Tuple[int, int]]
147
+ "tokenizations": datasets.features.Sequence(datasets.features.Sequence(datasets.Value("int32"), length=2)),
148
+ # Labels: Number is equal to number of unique pages across all folds
149
+ "answer": datasets.Value("string"),
150
+ "page": datasets.Value("string"),
151
+ "raw_answer": datasets.Value("string"),
152
+ # Meta Information
153
+ "fold": datasets.Value("string"),
154
+ "gameplay": datasets.Value("bool"),
155
+ "category": datasets.Value("string"),
156
+ "subcategory": datasets.Value("string"),
157
+ "tournament": datasets.Value("string"),
158
+ "difficulty": datasets.Value("string"),
159
+ "year": datasets.Value("int32"),
160
+ }
161
+
162
+
163
+ class Qanta(datasets.GeneratorBasedBuilder):
164
+ """The Qanta dataset is a question answering dataset based on the academic trivia game Quizbowl."""
165
+
166
+ VERSION = _VERSION
167
+ BUILDER_CONFIGS = [
168
+ QantaConfig(
169
+ name=f"mode={mode},char_skip={_DEFAULT_CHAR_SKIP}",
170
+ description=f"Question format: {mode}, char_skip: {_DEFAULT_CHAR_SKIP}",
171
+ mode=mode,
172
+ char_skip=_DEFAULT_CHAR_SKIP,
173
+ )
174
+ for mode in _MODES
175
+ ]
176
+
177
+ def _info(self):
178
+ return datasets.DatasetInfo(
179
+ # This is the description that will appear on the datasets page.
180
+ description=_DESCRIPTION,
181
+ # datasets.features.FeatureConnectors
182
+ features=datasets.Features(_FEATURES),
183
+ # Number of classes is a function of the dataset, ClassLabel doesn't support dynamic
184
+ # definition, so have to defer conversion to classes to later, so can't define
185
+ # supervied keys
186
+ supervised_keys=None,
187
+ # Homepage of the dataset for documentation
188
+ homepage="http://www.qanta.org/",
189
+ citation=_CITATION,
190
+ )
191
+
192
+ def _split_generators(self, dl_manager):
193
+ """Returns SplitGenerators."""
194
+ qanta_path = dl_manager.download_and_extract(_QANTA_URL)
195
+ trick_path = dl_manager.download_and_extract(_TRICK_URL)
196
+ return [
197
+ datasets.SplitGenerator(
198
+ name=datasets.Split("guesstrain"),
199
+ gen_kwargs={
200
+ "qanta_filepath": qanta_path,
201
+ "trick_filepath": trick_path,
202
+ "fold": "guesstrain",
203
+ "mode": self.config.mode,
204
+ "char_skip": self.config.char_skip,
205
+ },
206
+ ),
207
+ datasets.SplitGenerator(
208
+ name=datasets.Split("buzztrain"),
209
+ gen_kwargs={
210
+ "qanta_filepath": qanta_path,
211
+ "trick_filepath": trick_path,
212
+ "fold": "buzztrain",
213
+ "mode": self.config.mode,
214
+ "char_skip": self.config.char_skip,
215
+ },
216
+ ),
217
+ datasets.SplitGenerator(
218
+ name=datasets.Split("guessdev"),
219
+ gen_kwargs={
220
+ "qanta_filepath": qanta_path,
221
+ "trick_filepath": trick_path,
222
+ "fold": "guessdev",
223
+ "mode": self.config.mode,
224
+ "char_skip": self.config.char_skip,
225
+ },
226
+ ),
227
+ datasets.SplitGenerator(
228
+ name=datasets.Split("buzzdev"),
229
+ gen_kwargs={
230
+ "qanta_filepath": qanta_path,
231
+ "trick_filepath": trick_path,
232
+ "fold": "buzzdev",
233
+ "mode": self.config.mode,
234
+ "char_skip": self.config.char_skip,
235
+ },
236
+ ),
237
+ datasets.SplitGenerator(
238
+ name=datasets.Split("guesstest"),
239
+ gen_kwargs={
240
+ "qanta_filepath": qanta_path,
241
+ "trick_filepath": trick_path,
242
+ "fold": "guesstest",
243
+ "mode": self.config.mode,
244
+ "char_skip": self.config.char_skip,
245
+ },
246
+ ),
247
+ datasets.SplitGenerator(
248
+ name=datasets.Split("buzztest"),
249
+ gen_kwargs={
250
+ "qanta_filepath": qanta_path,
251
+ "trick_filepath": trick_path,
252
+ "fold": "buzztest",
253
+ "mode": self.config.mode,
254
+ "char_skip": self.config.char_skip,
255
+ },
256
+ ),
257
+ datasets.SplitGenerator(
258
+ name=datasets.Split("adversarial"),
259
+ gen_kwargs={
260
+ "qanta_filepath": qanta_path,
261
+ "trick_filepath": trick_path,
262
+ "fold": "adversarial",
263
+ "mode": self.config.mode,
264
+ "char_skip": self.config.char_skip,
265
+ },
266
+ ),
267
+ ]
268
+
269
+ def _generate_examples(
270
+ self,
271
+ qanta_filepath: str,
272
+ trick_filepath: str,
273
+ fold: str,
274
+ mode: str,
275
+ char_skip: int,
276
+ ):
277
+ """Yields examples."""
278
+ if mode not in _MODES:
279
+ raise ValueError(f"Invalid mode: {mode}")
280
+
281
+ if fold == "adversarial":
282
+ path = trick_filepath
283
+ else:
284
+ path = qanta_filepath
285
+ with open(path, encoding="utf-8") as f:
286
+ questions = json.load(f)["questions"]
287
+ for q in questions:
288
+ if q["page"] is not None and q["fold"] == fold:
289
+ for example in question_to_examples(q, mode, char_skip):
290
+ yield example["id"], example