albertvillanova HF staff commited on
Commit
885afd2
1 Parent(s): 67beed6

Delete loading script

Browse files
Files changed (1) hide show
  1. proto_qa.py +0 -208
proto_qa.py DELETED
@@ -1,208 +0,0 @@
1
- # coding=utf-8
2
- # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- """Dataset for ProtoQA ("family feud") data. The dataset is gathered from an existing set of questions played in a long-running international game show – FAMILY-FEUD."""
16
-
17
-
18
- import json
19
-
20
- import datasets
21
-
22
-
23
- _CITATION = """\
24
- @InProceedings{huggingface:dataset,
25
- title = {ProtoQA: A Question Answering Dataset for Prototypical Common-Sense Reasoning},
26
- authors={Michael Boratko, Xiang Lorraine Li, Tim O’Gorman, Rajarshi Das, Dan Le, Andrew McCallum},
27
- year={2020},
28
- publisher = {GitHub},
29
- journal = {GitHub repository},
30
- howpublished={\\url{https://github.com/iesl/protoqa-data}},
31
- }
32
- """
33
-
34
- _DESCRIPTION = """\
35
- This dataset is for studying computational models trained to reason about prototypical situations. Using deterministic filtering a sampling from a larger set of all transcriptions was built. It contains 9789 instances where each instance represents a survey question from Family Feud game. Each instance exactly is a question, a set of answers, and a count associated with each answer.
36
- Each line is a json dictionary, in which:
37
- 1. question - contains the question (in original and a normalized form)
38
- 2. answerstrings - contains the original answers provided by survey respondents (when available), along with the counts for each string. Because the FamilyFeud data has only cluster names rather than strings, those cluster names are included with 0 weight.
39
- 3. answer-clusters - lists clusters, with the count of each cluster and the strings included in that cluster. Each cluster is given a unique ID that can be linked to in the assessment files.
40
-
41
- """
42
-
43
- _HOMEPAGE = "https://github.com/iesl/protoqa-data"
44
-
45
- _LICENSE = "cc-by-4.0"
46
-
47
- _URLs = {
48
- "proto_qa": {
49
- "dev": "https://raw.githubusercontent.com/iesl/protoqa-data/9fb72b4e7d41a7d3a9766c33ef66c78d7a100b41/data/dev/protoqa_scraped_dev.jsonl",
50
- "train": "https://raw.githubusercontent.com/iesl/protoqa-data/9fb72b4e7d41a7d3a9766c33ef66c78d7a100b41/data/train/protoqa_train.jsonl",
51
- },
52
- "proto_qa_cs": "https://raw.githubusercontent.com/iesl/protoqa-data/9fb72b4e7d41a7d3a9766c33ef66c78d7a100b41/data/dev/crowdsource_dev.jsonl",
53
- "proto_qa_cs_assessments": "https://raw.githubusercontent.com/iesl/protoqa-data/9fb72b4e7d41a7d3a9766c33ef66c78d7a100b41/data/dev/crowdsource_dev.assessments.jsonl",
54
- }
55
-
56
-
57
- class ProtoQA(datasets.GeneratorBasedBuilder):
58
- """This is a question answering dataset for Prototypical Common-Sense Reasoning"""
59
-
60
- VERSION = datasets.Version("1.0.0")
61
-
62
- BUILDER_CONFIGS = [
63
- datasets.BuilderConfig(
64
- name="proto_qa",
65
- version=VERSION,
66
- description="This is a question answering dataset for Prototypical Common-Sense Reasoning",
67
- ),
68
- datasets.BuilderConfig(
69
- name="proto_qa_cs",
70
- version=VERSION,
71
- description="Prototypical Common-Sense Reasoning, 51 questions collected with exhaustive answer collection and manual clustering, matching the details of the eval test set",
72
- ),
73
- datasets.BuilderConfig(
74
- name="proto_qa_cs_assessments",
75
- version=VERSION,
76
- description="Prototypical Common-Sense Reasoning, assessment file for study of assessment methods",
77
- ),
78
- ]
79
-
80
- DEFAULT_CONFIG_NAME = "proto_qa"
81
-
82
- def _info(self):
83
- if self.config.name == "proto_qa_cs_assessments":
84
- features = datasets.Features(
85
- {
86
- "question": datasets.Value("string"),
87
- "assessments": datasets.Sequence(datasets.Value("string")),
88
- }
89
- )
90
- else:
91
-
92
- if self.config.name == "proto_qa_cs":
93
- label = "answers-cleaned"
94
- else:
95
- label = "answer-clusters"
96
- features = datasets.Features(
97
- {
98
- "normalized-question": datasets.Value("string"),
99
- "question": datasets.Value("string"),
100
- label: datasets.Sequence(
101
- {
102
- "count": datasets.Value("int32"),
103
- "clusterid": datasets.Value("string"),
104
- "answers": datasets.Sequence(datasets.Value("string")),
105
- }
106
- ),
107
- "answerstrings": datasets.Sequence(datasets.Value("string")),
108
- "totalcount": datasets.Value("int32"),
109
- "id": datasets.Value("string"),
110
- "source": datasets.Value("string"),
111
- }
112
- )
113
- return datasets.DatasetInfo(
114
- # This is the description that will appear on the datasets page.
115
- description=_DESCRIPTION,
116
- # This defines the different columns of the dataset and their types
117
- features=features, # Here we define them above because they are different between the two configurations
118
- supervised_keys=None,
119
- # Homepage of the dataset for documentation
120
- homepage=_HOMEPAGE,
121
- # License for the dataset if available
122
- license=_LICENSE,
123
- # Citation for the dataset
124
- citation=_CITATION,
125
- )
126
-
127
- def _split_generators(self, dl_manager):
128
- """Returns SplitGenerators."""
129
-
130
- if self.config.name == "proto_qa":
131
- train_fpath = dl_manager.download(_URLs[self.config.name]["train"])
132
- dev_fpath = dl_manager.download(_URLs[self.config.name]["dev"])
133
-
134
- return [
135
- datasets.SplitGenerator(
136
- name=datasets.Split.TRAIN,
137
- # These kwargs will be passed to _generate_examples
138
- gen_kwargs={
139
- "filepath": train_fpath,
140
- },
141
- ),
142
- datasets.SplitGenerator(
143
- name=datasets.Split.VALIDATION,
144
- # These kwargs will be passed to _generate_examples
145
- gen_kwargs={
146
- "filepath": dev_fpath,
147
- },
148
- ),
149
- ]
150
- else:
151
- filepath = dl_manager.download(_URLs[self.config.name])
152
- return [
153
- datasets.SplitGenerator(
154
- name=datasets.Split.VALIDATION,
155
- # These kwargs will be passed to _generate_examples
156
- gen_kwargs={
157
- "filepath": filepath,
158
- },
159
- )
160
- ]
161
-
162
- def _generate_examples(self, filepath):
163
- """Yields examples."""
164
-
165
- if self.config.name == "proto_qa_cs_assessments":
166
- with open(filepath, encoding="utf-8") as f:
167
- for id_, row in enumerate(f):
168
- data = json.loads(row)
169
- question = data["question"]
170
- assessments = data["assessments"]
171
-
172
- yield id_, {"question": question, "assessments": assessments}
173
-
174
- else:
175
- if self.config.name == "proto_qa_cs":
176
- label = "answers-cleaned"
177
- else:
178
- label = "answer-clusters"
179
-
180
- with open(filepath, encoding="utf-8") as f:
181
-
182
- for id_, row in enumerate(f):
183
-
184
- data = json.loads(row)
185
-
186
- normalized_question = data["question"]["normalized-question"]
187
- question = data["question"]["question"]
188
-
189
- answer_clusters = data[label]
190
-
191
- details = []
192
- for answer_cluster in answer_clusters:
193
- count = answer_cluster["count"]
194
- answers = answer_cluster["answers"]
195
- clusterid = answer_cluster["clusterid"]
196
- details.append({"count": count, "answers": answers, "clusterid": clusterid})
197
-
198
- answerstrings = data["answerstrings"]
199
- metadata = data["metadata"]
200
- yield id_, {
201
- "normalized-question": normalized_question,
202
- "question": question,
203
- label: details,
204
- "answerstrings": answerstrings,
205
- "totalcount": metadata["totalcount"],
206
- "id": metadata["id"],
207
- "source": metadata["source"],
208
- }