Datasets:

Languages:
English
Multilinguality:
monolingual
Size Categories:
10K<n<100K
Language Creators:
crowdsourced
Annotations Creators:
crowdsourced
Source Datasets:
original
Tags:
License:
albertvillanova HF staff commited on
Commit
8e45a81
1 Parent(s): 0441e53

Delete loading script

Browse files
Files changed (1) hide show
  1. break_data.py +0 -261
break_data.py DELETED
@@ -1,261 +0,0 @@
1
- """TODO(break_data): Add a description here."""
2
-
3
-
4
- import csv
5
- import json
6
- import os
7
- import textwrap
8
-
9
- import datasets
10
-
11
-
12
- # TODO(break): BibTeX citation
13
- _CITATION = """\
14
- @article{Wolfson2020Break,
15
- title={Break It Down: A Question Understanding Benchmark},
16
- author={Wolfson, Tomer and Geva, Mor and Gupta, Ankit and Gardner, Matt and Goldberg, Yoav and Deutch, Daniel and Berant, Jonathan},
17
- journal={Transactions of the Association for Computational Linguistics},
18
- year={2020},
19
- }
20
- """
21
-
22
- # TODO(break):
23
- _DESCRIPTION = """\
24
- Break is a human annotated dataset of natural language questions and their Question Decomposition Meaning Representations
25
- (QDMRs). Break consists of 83,978 examples sampled from 10 question answering datasets over text, images and databases.
26
- This repository contains the Break dataset along with information on the exact data format.
27
- """
28
- _URL = "https://github.com/allenai/Break/raw/master/break_dataset/Break-dataset.zip"
29
-
30
-
31
- class BreakDataConfig(datasets.BuilderConfig):
32
-
33
- """BuilderConfig for Break"""
34
-
35
- def __init__(self, text_features, lexicon_tokens, **kwargs):
36
- """
37
-
38
- Args:
39
- text_features: `dict[string, string]`, map from the name of the feature
40
- dict for each text field to the name of the column in the tsv file
41
- lexicon_tokens: to define if we want to load the lexicon_tokens files or not
42
- **kwargs: keyword arguments forwarded to super.
43
- """
44
- super(BreakDataConfig, self).__init__(version=datasets.Version("1.0.0", ""), **kwargs)
45
- self.text_features = text_features
46
- self.lexicon_tokens = lexicon_tokens
47
-
48
-
49
- class BreakData(datasets.GeneratorBasedBuilder):
50
- """TODO(break_data): Short description of my dataset."""
51
-
52
- # TODO(break_data): Set up version.
53
- VERSION = datasets.Version("0.1.0")
54
- BUILDER_CONFIGS = [
55
- BreakDataConfig(
56
- name="QDMR-high-level",
57
- description=textwrap.dedent(
58
- """
59
- Contains questions annotated with the high-level variant of QDMR. These decomposition are exclusive to Reading
60
- Comprehension tasks (Section 2). lexicon_tokens files are also provided."""
61
- ),
62
- text_features={
63
- "question_id": "question_id",
64
- "question_text": "question_text",
65
- "decomposition": "decomposition",
66
- "operators": "operators",
67
- "split": "split",
68
- },
69
- lexicon_tokens=False,
70
- ),
71
- BreakDataConfig(
72
- name="QDMR-high-level-lexicon",
73
- description=textwrap.dedent(
74
- """
75
- Contains questions annotated with the high-level variant of QDMR. These decomposition are exclusive to Reading
76
- Comprehension tasks (Section 2). lexicon_tokens files are also provided."""
77
- ),
78
- text_features={
79
- "source": "source",
80
- "allowed_tokens": "allowed_tokens",
81
- },
82
- lexicon_tokens=True,
83
- ),
84
- BreakDataConfig(
85
- name="QDMR",
86
- description=textwrap.dedent(
87
- """
88
- Contains questions over text, images and databases annotated with their Question Decomposition Meaning
89
- Representation. In addition to the train, dev and (hidden) test sets we provide lexicon_tokens files. For
90
- each question, the lexicon file contains the set of valid tokens that could potentially appear in its
91
- decomposition """
92
- ),
93
- text_features={
94
- "question_id": "question_id",
95
- "question_text": "question_text",
96
- "decomposition": "decomposition",
97
- "operators": "operators",
98
- "split": "split",
99
- },
100
- lexicon_tokens=False,
101
- ),
102
- BreakDataConfig(
103
- name="QDMR-lexicon",
104
- description=textwrap.dedent(
105
- """
106
- Contains questions over text, images and databases annotated with their Question Decomposition Meaning
107
- Representation. In addition to the train, dev and (hidden) test sets we provide lexicon_tokens files. For
108
- each question, the lexicon file contains the set of valid tokens that could potentially appear in its
109
- decomposition """
110
- ),
111
- text_features={
112
- "source": "source",
113
- "allowed_tokens": "allowed_tokens",
114
- },
115
- lexicon_tokens=True,
116
- ),
117
- BreakDataConfig(
118
- name="logical-forms",
119
- description=textwrap.dedent(
120
- """
121
- Contains questions and QDMRs annotated with full logical-forms of QDMR operators + arguments. Full logical-forms
122
- were inferred by the annotation-consistency algorithm described in """
123
- ),
124
- lexicon_tokens=False,
125
- text_features={
126
- "question_id": "question_id",
127
- "question_text": "question_text",
128
- "decomposition": "decomposition",
129
- "operators": "operators",
130
- "split": "split",
131
- "program": "program",
132
- },
133
- ),
134
- ]
135
-
136
- def _info(self):
137
- # TODO(break_data): Specifies the datasets.DatasetInfo object
138
- features = {text_feature: datasets.Value("string") for text_feature in self.config.text_features.keys()}
139
- return datasets.DatasetInfo(
140
- # This is the description that will appear on the datasets page.
141
- description=_DESCRIPTION,
142
- # datasets.features.FeatureConnectors
143
- features=datasets.Features(
144
- features
145
- # These are the features of your dataset like images, labels ...
146
- ),
147
- # If there's a common (input, target) tuple from the features,
148
- # specify them here. They'll be used if as_supervised=True in
149
- # builder.as_dataset.
150
- supervised_keys=None,
151
- # Homepage of the dataset for documentation
152
- homepage="https://github.com/allenai/Break",
153
- citation=_CITATION,
154
- )
155
- # if
156
-
157
- def _split_generators(self, dl_manager):
158
- """Returns SplitGenerators."""
159
- # TODO(break_data): Downloads the data and defines the splits
160
- # dl_manager is a datasets.download.DownloadManager that can be used to
161
- # download and extract URLs
162
- dl_dir = dl_manager.download_and_extract(_URL)
163
- data_dir = os.path.join(dl_dir, "Break-dataset")
164
- qdmr_high_level = os.path.join(data_dir, "QDMR-high-level")
165
- qdmr = os.path.join(data_dir, "QDMR")
166
- logical = os.path.join(data_dir, "logical-forms")
167
- if self.config.name == "QDMR" or self.config.name == "QDMR-lexicon":
168
- return [
169
- datasets.SplitGenerator(
170
- name=datasets.Split.TRAIN,
171
- # These kwargs will be passed to _generate_examples
172
- gen_kwargs={
173
- "filepath": os.path.join(qdmr, "train.csv")
174
- if not self.config.lexicon_tokens
175
- else os.path.join(qdmr, "train_lexicon_tokens.json")
176
- },
177
- ),
178
- datasets.SplitGenerator(
179
- name=datasets.Split.VALIDATION,
180
- # These kwargs will be passed to _generate_examples
181
- gen_kwargs={
182
- "filepath": os.path.join(qdmr, "dev.csv")
183
- if not self.config.lexicon_tokens
184
- else os.path.join(qdmr, "dev_lexicon_tokens.json")
185
- },
186
- ),
187
- datasets.SplitGenerator(
188
- name=datasets.Split.TEST,
189
- # These kwargs will be passed to _generate_examples
190
- gen_kwargs={
191
- "filepath": os.path.join(qdmr, "test.csv")
192
- if not self.config.lexicon_tokens
193
- else os.path.join(qdmr, "test_lexicon_tokens.json")
194
- },
195
- ),
196
- ]
197
- elif self.config.name == "QDMR-high-level" or self.config.name == "QDMR-high-level-lexicon":
198
- return [
199
- datasets.SplitGenerator(
200
- name=datasets.Split.TRAIN,
201
- # These kwargs will be passed to _generate_examples
202
- gen_kwargs={
203
- "filepath": os.path.join(qdmr_high_level, "train.csv")
204
- if not self.config.lexicon_tokens
205
- else os.path.join(qdmr_high_level, "train_lexicon_tokens.json")
206
- },
207
- ),
208
- datasets.SplitGenerator(
209
- name=datasets.Split.VALIDATION,
210
- # These kwargs will be passed to _generate_examples
211
- gen_kwargs={
212
- "filepath": os.path.join(qdmr_high_level, "dev.csv")
213
- if not self.config.lexicon_tokens
214
- else os.path.join(qdmr_high_level, "dev_lexicon_tokens.json")
215
- },
216
- ),
217
- datasets.SplitGenerator(
218
- name=datasets.Split.TEST,
219
- # These kwargs will be passed to _generate_examples
220
- gen_kwargs={
221
- "filepath": os.path.join(qdmr_high_level, "test.csv")
222
- if not self.config.lexicon_tokens
223
- else os.path.join(qdmr_high_level, "test_lexicon_tokens.json")
224
- },
225
- ),
226
- ]
227
- elif self.config.name == "logical-forms":
228
- return [
229
- datasets.SplitGenerator(
230
- name=datasets.Split.TRAIN,
231
- # These kwargs will be passed to _generate_examples
232
- gen_kwargs={"filepath": os.path.join(logical, "train.csv")},
233
- ),
234
- datasets.SplitGenerator(
235
- name=datasets.Split.VALIDATION,
236
- # These kwargs will be passed to _generate_examples
237
- gen_kwargs={"filepath": os.path.join(logical, "dev.csv")},
238
- ),
239
- datasets.SplitGenerator(
240
- name=datasets.Split.TEST,
241
- # These kwargs will be passed to _generate_examples
242
- gen_kwargs={"filepath": os.path.join(logical, "test.csv")},
243
- ),
244
- ]
245
-
246
- def _generate_examples(self, filepath):
247
- """Yields examples."""
248
- # TODO(break_data): Yields (key, example) tuples from the dataset
249
- with open(filepath, encoding="utf-8") as f:
250
- if (
251
- self.config.name == "QDMR-high-level"
252
- or self.config.name == "QDMR"
253
- or self.config.name == "logical-forms"
254
- ):
255
- data = csv.DictReader(f)
256
- for id_, row in enumerate(data):
257
- yield id_, row
258
- elif self.config.name == "QDMR-high-level-lexicon" or self.config.name == "QDMR-lexicon":
259
- for id_, row in enumerate(f):
260
- data = json.loads(row)
261
- yield id_, data