Datasets:
Delete loading script
Browse files
quac.py
DELETED
@@ -1,171 +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 |
-
"""QUAC (Question Answering in Context)."""
|
16 |
-
|
17 |
-
|
18 |
-
import json
|
19 |
-
|
20 |
-
import datasets
|
21 |
-
|
22 |
-
|
23 |
-
_CITATION = """\
|
24 |
-
@inproceedings{choi-etal-2018-quac,
|
25 |
-
title = "QUAC: Question answering in context",
|
26 |
-
abstract = "We present QuAC, a dataset for Question Answering in Context that contains 14K information-seeking QA dialogs (100K questions in total). The dialogs involve two crowd workers: (1) a student who poses a sequence of freeform questions to learn as much as possible about a hidden Wikipedia text, and (2) a teacher who answers the questions by providing short excerpts from the text. QuAC introduces challenges not found in existing machine comprehension datasets: its questions are often more open-ended, unanswerable, or only meaningful within the dialog context, as we show in a detailed qualitative evaluation. We also report results for a number of reference models, including a recently state-of-the-art reading comprehension architecture extended to model dialog context. Our best model underperforms humans by 20 F1, suggesting that there is significant room for future work on this data. Dataset, baseline, and leaderboard available at http://quac.ai.",
|
27 |
-
author = "Eunsol Choi and He He and Mohit Iyyer and Mark Yatskar and Yih, {Wen Tau} and Yejin Choi and Percy Liang and Luke Zettlemoyer",
|
28 |
-
year = "2018",
|
29 |
-
language = "English (US)",
|
30 |
-
series = "Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, EMNLP 2018",
|
31 |
-
publisher = "Association for Computational Linguistics",
|
32 |
-
pages = "2174--2184",
|
33 |
-
editor = "Ellen Riloff and David Chiang and Julia Hockenmaier and Jun'ichi Tsujii",
|
34 |
-
booktitle = "Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing, EMNLP 2018",
|
35 |
-
note = "2018 Conference on Empirical Methods in Natural Language Processing, EMNLP 2018 ; Conference date: 31-10-2018 Through 04-11-2018",
|
36 |
-
}
|
37 |
-
"""
|
38 |
-
|
39 |
-
_DESCRIPTION = """\
|
40 |
-
Question Answering in Context is a dataset for modeling, understanding,
|
41 |
-
and participating in information seeking dialog. Data instances consist
|
42 |
-
of an interactive dialog between two crowd workers: (1) a student who
|
43 |
-
poses a sequence of freeform questions to learn as much as possible
|
44 |
-
about a hidden Wikipedia text, and (2) a teacher who answers the questions
|
45 |
-
by providing short excerpts (spans) from the text. QuAC introduces
|
46 |
-
challenges not found in existing machine comprehension datasets: its
|
47 |
-
questions are often more open-ended, unanswerable, or only meaningful
|
48 |
-
within the dialog context.
|
49 |
-
"""
|
50 |
-
|
51 |
-
_HOMEPAGE = "https://quac.ai/"
|
52 |
-
|
53 |
-
_LICENSE = "MIT"
|
54 |
-
|
55 |
-
_URLs = {
|
56 |
-
"train": "https://s3.amazonaws.com/my89public/quac/train_v0.2.json",
|
57 |
-
"validation": "https://s3.amazonaws.com/my89public/quac/val_v0.2.json",
|
58 |
-
}
|
59 |
-
|
60 |
-
|
61 |
-
class Quac(datasets.GeneratorBasedBuilder):
|
62 |
-
"""QuAC (Question Answering in Context)."""
|
63 |
-
|
64 |
-
VERSION = datasets.Version("1.1.0")
|
65 |
-
|
66 |
-
BUILDER_CONFIGS = [
|
67 |
-
datasets.BuilderConfig(
|
68 |
-
name="plain_text",
|
69 |
-
description="Plain text",
|
70 |
-
version=VERSION,
|
71 |
-
),
|
72 |
-
]
|
73 |
-
|
74 |
-
def _info(self):
|
75 |
-
return datasets.DatasetInfo(
|
76 |
-
description=_DESCRIPTION,
|
77 |
-
features=datasets.Features(
|
78 |
-
{
|
79 |
-
"dialogue_id": datasets.Value("string"),
|
80 |
-
"wikipedia_page_title": datasets.Value("string"),
|
81 |
-
"background": datasets.Value("string"),
|
82 |
-
"section_title": datasets.Value("string"),
|
83 |
-
"context": datasets.Value("string"),
|
84 |
-
"turn_ids": datasets.Sequence(datasets.Value("string")),
|
85 |
-
"questions": datasets.Sequence(datasets.Value("string")),
|
86 |
-
"followups": datasets.Sequence(datasets.ClassLabel(names=["y", "n", "m"])),
|
87 |
-
"yesnos": datasets.Sequence(datasets.ClassLabel(names=["y", "n", "x"])),
|
88 |
-
"answers": datasets.Sequence(
|
89 |
-
{
|
90 |
-
"texts": datasets.Sequence(datasets.Value("string")),
|
91 |
-
"answer_starts": datasets.Sequence(datasets.Value("int32")),
|
92 |
-
}
|
93 |
-
),
|
94 |
-
"orig_answers": {
|
95 |
-
"texts": datasets.Sequence(datasets.Value("string")),
|
96 |
-
"answer_starts": datasets.Sequence(datasets.Value("int32")),
|
97 |
-
},
|
98 |
-
}
|
99 |
-
),
|
100 |
-
supervised_keys=None,
|
101 |
-
homepage=_HOMEPAGE,
|
102 |
-
license=_LICENSE,
|
103 |
-
citation=_CITATION,
|
104 |
-
)
|
105 |
-
|
106 |
-
def _split_generators(self, dl_manager):
|
107 |
-
"""Returns SplitGenerators."""
|
108 |
-
data_dir = dl_manager.download_and_extract(_URLs)
|
109 |
-
return [
|
110 |
-
datasets.SplitGenerator(
|
111 |
-
name=datasets.Split.TRAIN,
|
112 |
-
gen_kwargs={
|
113 |
-
"filepath": data_dir["train"],
|
114 |
-
},
|
115 |
-
),
|
116 |
-
datasets.SplitGenerator(
|
117 |
-
name=datasets.Split.VALIDATION,
|
118 |
-
gen_kwargs={
|
119 |
-
"filepath": data_dir["validation"],
|
120 |
-
},
|
121 |
-
),
|
122 |
-
]
|
123 |
-
|
124 |
-
def _generate_examples(self, filepath):
|
125 |
-
"""Yields examples."""
|
126 |
-
with open(filepath, encoding="utf-8") as f:
|
127 |
-
squad = json.load(f)
|
128 |
-
for section in squad["data"]:
|
129 |
-
wiki_page_title = section.get("title", "").strip()
|
130 |
-
background = section.get("background", "").strip()
|
131 |
-
section_title = section.get("section_title", "").strip()
|
132 |
-
|
133 |
-
for dialogue in section["paragraphs"]:
|
134 |
-
context = dialogue["context"].strip()
|
135 |
-
dialogue_id = dialogue["id"]
|
136 |
-
|
137 |
-
followups = []
|
138 |
-
yesnos = []
|
139 |
-
questions = []
|
140 |
-
turn_ids = []
|
141 |
-
answers = []
|
142 |
-
orig_answers = {"texts": [], "answer_starts": []}
|
143 |
-
|
144 |
-
for turn in dialogue["qas"]:
|
145 |
-
followups.append(turn["followup"])
|
146 |
-
yesnos.append(turn["yesno"])
|
147 |
-
questions.append(turn["question"])
|
148 |
-
turn_ids.append(turn["id"])
|
149 |
-
|
150 |
-
ans_ = {
|
151 |
-
"texts": [t["text"].strip() for t in turn["answers"]],
|
152 |
-
"answer_starts": [t["answer_start"] for t in turn["answers"]],
|
153 |
-
}
|
154 |
-
answers.append(ans_)
|
155 |
-
|
156 |
-
orig_answers["texts"].append(turn["orig_answer"]["text"])
|
157 |
-
orig_answers["answer_starts"].append(turn["orig_answer"]["answer_start"])
|
158 |
-
|
159 |
-
yield dialogue_id, {
|
160 |
-
"dialogue_id": dialogue_id,
|
161 |
-
"wikipedia_page_title": wiki_page_title,
|
162 |
-
"background": background,
|
163 |
-
"section_title": section_title,
|
164 |
-
"context": context,
|
165 |
-
"turn_ids": turn_ids,
|
166 |
-
"questions": questions,
|
167 |
-
"followups": followups,
|
168 |
-
"yesnos": yesnos,
|
169 |
-
"answers": answers,
|
170 |
-
"orig_answers": orig_answers,
|
171 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|