rishabbala
commited on
Commit
•
06f1eec
1
Parent(s):
25a83ff
Delete loading script
Browse files
wiqa.py
DELETED
@@ -1,113 +0,0 @@
|
|
1 |
-
"""TODO(wiqa): Add a description here."""
|
2 |
-
|
3 |
-
|
4 |
-
import json
|
5 |
-
import os
|
6 |
-
|
7 |
-
import datasets
|
8 |
-
|
9 |
-
|
10 |
-
# TODO(wiqa): BibTeX citation
|
11 |
-
_CITATION = """\
|
12 |
-
@article{wiqa,
|
13 |
-
author = {Niket Tandon and Bhavana Dalvi Mishra and Keisuke Sakaguchi and Antoine Bosselut and Peter Clark}
|
14 |
-
title = {WIQA: A dataset for "What if..." reasoning over procedural text},
|
15 |
-
journal = {arXiv:1909.04739v1},
|
16 |
-
year = {2019},
|
17 |
-
}
|
18 |
-
"""
|
19 |
-
|
20 |
-
# TODO(wiqa):
|
21 |
-
_DESCRIPTION = """\
|
22 |
-
The WIQA dataset V1 has 39705 questions containing a perturbation and a possible effect in the context of a paragraph.
|
23 |
-
The dataset is split into 29808 train questions, 6894 dev questions and 3003 test questions.
|
24 |
-
"""
|
25 |
-
_URL = "https://public-aristo-processes.s3-us-west-2.amazonaws.com/wiqa_dataset_no_explanation_v2/wiqa-dataset-v2-october-2019.zip"
|
26 |
-
URl = "s3://ai2-s2-research-public/open-corpus/2020-04-10/"
|
27 |
-
|
28 |
-
|
29 |
-
class Wiqa(datasets.GeneratorBasedBuilder):
|
30 |
-
"""TODO(wiqa): Short description of my dataset."""
|
31 |
-
|
32 |
-
# TODO(wiqa): Set up version.
|
33 |
-
VERSION = datasets.Version("0.1.0")
|
34 |
-
|
35 |
-
def _info(self):
|
36 |
-
# TODO(wiqa): Specifies the datasets.DatasetInfo object
|
37 |
-
return datasets.DatasetInfo(
|
38 |
-
# This is the description that will appear on the datasets page.
|
39 |
-
description=_DESCRIPTION,
|
40 |
-
# datasets.features.FeatureConnectors
|
41 |
-
features=datasets.Features(
|
42 |
-
{
|
43 |
-
# These are the features of your dataset like images, labels ...
|
44 |
-
"question_stem": datasets.Value("string"),
|
45 |
-
"question_para_step": datasets.features.Sequence(datasets.Value("string")),
|
46 |
-
"answer_label": datasets.Value("string"),
|
47 |
-
"answer_label_as_choice": datasets.Value("string"),
|
48 |
-
"choices": datasets.features.Sequence(
|
49 |
-
{"text": datasets.Value("string"), "label": datasets.Value("string")}
|
50 |
-
),
|
51 |
-
"metadata_question_id": datasets.Value("string"),
|
52 |
-
"metadata_graph_id": datasets.Value("string"),
|
53 |
-
"metadata_para_id": datasets.Value("string"),
|
54 |
-
"metadata_question_type": datasets.Value("string"),
|
55 |
-
"metadata_path_len": datasets.Value("int32"),
|
56 |
-
}
|
57 |
-
),
|
58 |
-
# If there's a common (input, target) tuple from the features,
|
59 |
-
# specify them here. They'll be used if as_supervised=True in
|
60 |
-
# builder.as_dataset.
|
61 |
-
supervised_keys=None,
|
62 |
-
# Homepage of the dataset for documentation
|
63 |
-
homepage="https://allenai.org/data/wiqa",
|
64 |
-
citation=_CITATION,
|
65 |
-
)
|
66 |
-
|
67 |
-
def _split_generators(self, dl_manager):
|
68 |
-
"""Returns SplitGenerators."""
|
69 |
-
# TODO(wiqa): Downloads the data and defines the splits
|
70 |
-
# dl_manager is a datasets.download.DownloadManager that can be used to
|
71 |
-
# download and extract URLs
|
72 |
-
dl_dir = dl_manager.download_and_extract(_URL)
|
73 |
-
|
74 |
-
return [
|
75 |
-
datasets.SplitGenerator(
|
76 |
-
name=datasets.Split.TRAIN,
|
77 |
-
# These kwargs will be passed to _generate_examples
|
78 |
-
gen_kwargs={"filepath": os.path.join(dl_dir, "train.jsonl")},
|
79 |
-
),
|
80 |
-
datasets.SplitGenerator(
|
81 |
-
name=datasets.Split.TEST,
|
82 |
-
# These kwargs will be passed to _generate_examples
|
83 |
-
gen_kwargs={"filepath": os.path.join(dl_dir, "test.jsonl")},
|
84 |
-
),
|
85 |
-
datasets.SplitGenerator(
|
86 |
-
name=datasets.Split.VALIDATION,
|
87 |
-
# These kwargs will be passed to _generate_examples
|
88 |
-
gen_kwargs={"filepath": os.path.join(dl_dir, "dev.jsonl")},
|
89 |
-
),
|
90 |
-
]
|
91 |
-
|
92 |
-
def _generate_examples(self, filepath):
|
93 |
-
"""Yields examples."""
|
94 |
-
# TODO(wiqa): Yields (key, example) tuples from the dataset
|
95 |
-
with open(filepath, encoding="utf-8") as f:
|
96 |
-
for id_, row in enumerate(f):
|
97 |
-
data = json.loads(row)
|
98 |
-
|
99 |
-
yield id_, {
|
100 |
-
"question_stem": data["question"]["stem"],
|
101 |
-
"question_para_step": data["question"]["para_steps"],
|
102 |
-
"answer_label": data["question"]["answer_label"],
|
103 |
-
"answer_label_as_choice": data["question"]["answer_label_as_choice"],
|
104 |
-
"choices": {
|
105 |
-
"text": [choice["text"] for choice in data["question"]["choices"]],
|
106 |
-
"label": [choice["label"] for choice in data["question"]["choices"]],
|
107 |
-
},
|
108 |
-
"metadata_question_id": data["metadata"]["ques_id"],
|
109 |
-
"metadata_graph_id": data["metadata"]["graph_id"],
|
110 |
-
"metadata_para_id": data["metadata"]["para_id"],
|
111 |
-
"metadata_question_type": data["metadata"]["question_type"],
|
112 |
-
"metadata_path_len": data["metadata"]["path_len"],
|
113 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|