Datasets:
Tasks:
Question Answering
Formats:
parquet
Sub-tasks:
multiple-choice-qa
Languages:
English
Size:
10K - 100K
ArXiv:
License:
Delete loading script
Browse files
codah.py
DELETED
@@ -1,141 +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 |
-
"""The COmmonsense Dataset Adversarially-authored by Humans (CODAH)"""
|
16 |
-
|
17 |
-
|
18 |
-
import csv
|
19 |
-
|
20 |
-
import datasets
|
21 |
-
|
22 |
-
|
23 |
-
_CITATION = """\
|
24 |
-
@inproceedings{chen2019codah,
|
25 |
-
title={CODAH: An Adversarially-Authored Question Answering Dataset for Common Sense},
|
26 |
-
author={Chen, Michael and D'Arcy, Mike and Liu, Alisa and Fernandez, Jared and Downey, Doug},
|
27 |
-
booktitle={Proceedings of the 3rd Workshop on Evaluating Vector Space Representations for NLP},
|
28 |
-
pages={63--69},
|
29 |
-
year={2019}
|
30 |
-
}
|
31 |
-
"""
|
32 |
-
|
33 |
-
_DESCRIPTION = """\
|
34 |
-
The COmmonsense Dataset Adversarially-authored by Humans (CODAH) is an evaluation set for commonsense \
|
35 |
-
question-answering in the sentence completion style of SWAG. As opposed to other automatically \
|
36 |
-
generated NLI datasets, CODAH is adversarially constructed by humans who can view feedback \
|
37 |
-
from a pre-trained model and use this information to design challenging commonsense questions. \
|
38 |
-
Our experimental results show that CODAH questions present a complementary extension to the SWAG dataset, testing additional modes of common sense.
|
39 |
-
"""
|
40 |
-
|
41 |
-
_URL = "https://raw.githubusercontent.com/Websail-NU/CODAH/master/data/"
|
42 |
-
_FULL_DATA_URL = _URL + "full_data.tsv"
|
43 |
-
|
44 |
-
QUESTION_CATEGORIES_MAPPING = {
|
45 |
-
"i": "Idioms",
|
46 |
-
"r": "Reference",
|
47 |
-
"p": "Polysemy",
|
48 |
-
"n": "Negation",
|
49 |
-
"q": "Quantitative",
|
50 |
-
"o": "Others",
|
51 |
-
}
|
52 |
-
|
53 |
-
|
54 |
-
class CodahConfig(datasets.BuilderConfig):
|
55 |
-
"""BuilderConfig for CODAH."""
|
56 |
-
|
57 |
-
def __init__(self, fold=None, **kwargs):
|
58 |
-
"""BuilderConfig for CODAH.
|
59 |
-
|
60 |
-
Args:
|
61 |
-
fold: `string`, official cross validation fold.
|
62 |
-
**kwargs: keyword arguments forwarded to super.
|
63 |
-
"""
|
64 |
-
super(CodahConfig, self).__init__(**kwargs)
|
65 |
-
self.fold = fold
|
66 |
-
|
67 |
-
|
68 |
-
class Codah(datasets.GeneratorBasedBuilder):
|
69 |
-
"""The COmmonsense Dataset Adversarially-authored by Humans (CODAH)"""
|
70 |
-
|
71 |
-
VERSION = datasets.Version("1.0.0")
|
72 |
-
BUILDER_CONFIGS = [
|
73 |
-
CodahConfig(name="codah", version=datasets.Version("1.0.0"), description="Full CODAH dataset", fold=None),
|
74 |
-
CodahConfig(
|
75 |
-
name="fold_0", version=datasets.Version("1.0.0"), description="Official CV split (fold_0)", fold="fold_0"
|
76 |
-
),
|
77 |
-
CodahConfig(
|
78 |
-
name="fold_1", version=datasets.Version("1.0.0"), description="Official CV split (fold_1)", fold="fold_1"
|
79 |
-
),
|
80 |
-
CodahConfig(
|
81 |
-
name="fold_2", version=datasets.Version("1.0.0"), description="Official CV split (fold_2)", fold="fold_2"
|
82 |
-
),
|
83 |
-
CodahConfig(
|
84 |
-
name="fold_3", version=datasets.Version("1.0.0"), description="Official CV split (fold_3)", fold="fold_3"
|
85 |
-
),
|
86 |
-
CodahConfig(
|
87 |
-
name="fold_4", version=datasets.Version("1.0.0"), description="Official CV split (fold_4)", fold="fold_4"
|
88 |
-
),
|
89 |
-
]
|
90 |
-
|
91 |
-
def _info(self):
|
92 |
-
return datasets.DatasetInfo(
|
93 |
-
description=_DESCRIPTION,
|
94 |
-
features=datasets.Features(
|
95 |
-
{
|
96 |
-
"id": datasets.Value("int32"),
|
97 |
-
"question_category": datasets.features.ClassLabel(
|
98 |
-
names=["Idioms", "Reference", "Polysemy", "Negation", "Quantitative", "Others"]
|
99 |
-
),
|
100 |
-
"question_propmt": datasets.Value("string"),
|
101 |
-
"candidate_answers": datasets.features.Sequence(datasets.Value("string")),
|
102 |
-
"correct_answer_idx": datasets.Value("int32"),
|
103 |
-
}
|
104 |
-
),
|
105 |
-
supervised_keys=None,
|
106 |
-
homepage="https://github.com/Websail-NU/CODAH",
|
107 |
-
citation=_CITATION,
|
108 |
-
)
|
109 |
-
|
110 |
-
def _split_generators(self, dl_manager):
|
111 |
-
if self.config.name == "codah":
|
112 |
-
data_file = dl_manager.download(_FULL_DATA_URL)
|
113 |
-
return [datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"data_file": data_file})]
|
114 |
-
|
115 |
-
base_url = f"{_URL}cv_split/{self.config.fold}/"
|
116 |
-
_urls = {
|
117 |
-
"train": base_url + "train.tsv",
|
118 |
-
"dev": base_url + "dev.tsv",
|
119 |
-
"test": base_url + "test.tsv",
|
120 |
-
}
|
121 |
-
downloaded_files = dl_manager.download_and_extract(_urls)
|
122 |
-
|
123 |
-
return [
|
124 |
-
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"data_file": downloaded_files["train"]}),
|
125 |
-
datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"data_file": downloaded_files["dev"]}),
|
126 |
-
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"data_file": downloaded_files["test"]}),
|
127 |
-
]
|
128 |
-
|
129 |
-
def _generate_examples(self, data_file):
|
130 |
-
with open(data_file, encoding="utf-8") as f:
|
131 |
-
rows = csv.reader(f, delimiter="\t")
|
132 |
-
for i, row in enumerate(rows):
|
133 |
-
question_category = QUESTION_CATEGORIES_MAPPING[row[0]] if row[0] != "" else -1
|
134 |
-
example = {
|
135 |
-
"id": i,
|
136 |
-
"question_category": question_category,
|
137 |
-
"question_propmt": row[1],
|
138 |
-
"candidate_answers": row[2:-1],
|
139 |
-
"correct_answer_idx": int(row[-1]),
|
140 |
-
}
|
141 |
-
yield i, example
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|