Delete loading script
Browse files- riddle_sense.py +0 -126
riddle_sense.py
DELETED
|
@@ -1,126 +0,0 @@
|
|
| 1 |
-
import json
|
| 2 |
-
|
| 3 |
-
import datasets
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
_CITATION = """\
|
| 7 |
-
@InProceedings{lin-etal-2021-riddlesense,
|
| 8 |
-
title={RiddleSense: Reasoning about Riddle Questions Featuring Linguistic Creativity and Commonsense Knowledge},
|
| 9 |
-
author={Lin, Bill Yuchen and Wu, Ziyi and Yang, Yichi and Lee, Dong-Ho and Ren, Xiang},
|
| 10 |
-
journal={Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics (ACL-IJCNLP 2021): Findings},
|
| 11 |
-
year={2021}
|
| 12 |
-
}
|
| 13 |
-
"""
|
| 14 |
-
|
| 15 |
-
_DESCRIPTION = """\
|
| 16 |
-
Answering such a riddle-style question is a challenging cognitive process, in that it requires
|
| 17 |
-
complex commonsense reasoning abilities, an understanding of figurative language, and counterfactual reasoning
|
| 18 |
-
skills, which are all important abilities for advanced natural language understanding (NLU). However,
|
| 19 |
-
there is currently no dedicated datasets aiming to test these abilities. Herein, we present RiddleSense,
|
| 20 |
-
a new multiple-choice question answering task, which comes with the first large dataset (5.7k examples) for answering
|
| 21 |
-
riddle-style commonsense questions. We systematically evaluate a wide range of models over the challenge,
|
| 22 |
-
and point out that there is a large gap between the best-supervised model and human performance — suggesting
|
| 23 |
-
intriguing future research in the direction of higher-order commonsense reasoning and linguistic creativity towards
|
| 24 |
-
building advanced NLU systems.
|
| 25 |
-
|
| 26 |
-
"""
|
| 27 |
-
|
| 28 |
-
_LICENSE = """\
|
| 29 |
-
The copyright of RiddleSense dataset is consistent with the terms of use of the fan websites and the intellectual
|
| 30 |
-
property and privacy rights of the original sources. All of our riddles and answers are from fan websites that can be
|
| 31 |
-
accessed freely. The website owners state that you may print and download material from the sites solely for non
|
| 32 |
-
commercial use provided that we agree not to change or delete any copyright or proprietary notices from the
|
| 33 |
-
materials. The dataset users must agree that they will only use the dataset for research purposes before they can
|
| 34 |
-
access the both the riddles and our annotations. We do not vouch for the potential bias or fairness issue that might
|
| 35 |
-
exist within the riddles. You do not have the right to redistribute them. Again, you must not use this dataset for any
|
| 36 |
-
commercial purposes.
|
| 37 |
-
"""
|
| 38 |
-
|
| 39 |
-
_URL = "https://inklab.usc.edu/RiddleSense/riddlesense_dataset/"
|
| 40 |
-
_URLS = {
|
| 41 |
-
"train": _URL + "rs_train.jsonl",
|
| 42 |
-
"dev": _URL + "rs_dev.jsonl",
|
| 43 |
-
"test": _URL + "rs_test_hidden.jsonl",
|
| 44 |
-
}
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
class RiddleSense(datasets.GeneratorBasedBuilder):
|
| 48 |
-
|
| 49 |
-
VERSION = datasets.Version("0.1.0")
|
| 50 |
-
|
| 51 |
-
def _info(self):
|
| 52 |
-
# These are the features of your dataset like images, labels ...
|
| 53 |
-
features = datasets.Features(
|
| 54 |
-
{
|
| 55 |
-
"answerKey": datasets.Value("string"),
|
| 56 |
-
"question": datasets.Value("string"),
|
| 57 |
-
"choices": datasets.features.Sequence(
|
| 58 |
-
{
|
| 59 |
-
"label": datasets.Value("string"),
|
| 60 |
-
"text": datasets.Value("string"),
|
| 61 |
-
}
|
| 62 |
-
),
|
| 63 |
-
}
|
| 64 |
-
)
|
| 65 |
-
return datasets.DatasetInfo(
|
| 66 |
-
# This is the description that will appear on the datasets page.
|
| 67 |
-
description=_DESCRIPTION,
|
| 68 |
-
# datasets.features.FeatureConnectors
|
| 69 |
-
features=features,
|
| 70 |
-
# If there's a common (input, target) tuple from the features,
|
| 71 |
-
# specify them here. They'll be used if as_supervised=True in
|
| 72 |
-
# builder.as_dataset.
|
| 73 |
-
supervised_keys=None,
|
| 74 |
-
# Homepage of the dataset for documentation
|
| 75 |
-
homepage="https://inklab.usc.edu/RiddleSense/",
|
| 76 |
-
citation=_CITATION,
|
| 77 |
-
license=_LICENSE,
|
| 78 |
-
)
|
| 79 |
-
|
| 80 |
-
def _split_generators(self, dl_manager):
|
| 81 |
-
"""Returns SplitGenerators."""
|
| 82 |
-
|
| 83 |
-
download_urls = _URLS
|
| 84 |
-
|
| 85 |
-
downloaded_files = dl_manager.download_and_extract(download_urls)
|
| 86 |
-
|
| 87 |
-
return [
|
| 88 |
-
datasets.SplitGenerator(
|
| 89 |
-
name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"], "split": "train"}
|
| 90 |
-
),
|
| 91 |
-
datasets.SplitGenerator(
|
| 92 |
-
name=datasets.Split.VALIDATION,
|
| 93 |
-
gen_kwargs={
|
| 94 |
-
"filepath": downloaded_files["dev"],
|
| 95 |
-
"split": "dev",
|
| 96 |
-
},
|
| 97 |
-
),
|
| 98 |
-
datasets.SplitGenerator(
|
| 99 |
-
name=datasets.Split.TEST,
|
| 100 |
-
gen_kwargs={
|
| 101 |
-
"filepath": downloaded_files["test"],
|
| 102 |
-
"split": "test",
|
| 103 |
-
},
|
| 104 |
-
),
|
| 105 |
-
]
|
| 106 |
-
|
| 107 |
-
def _generate_examples(self, filepath, split):
|
| 108 |
-
"""Yields examples."""
|
| 109 |
-
with open(filepath, encoding="utf-8") as f:
|
| 110 |
-
for id_, row in enumerate(f):
|
| 111 |
-
data = json.loads(row)
|
| 112 |
-
question = data["question"]
|
| 113 |
-
choices = question["choices"]
|
| 114 |
-
labels = [label["label"] for label in choices]
|
| 115 |
-
texts = [text["text"] for text in choices]
|
| 116 |
-
stem = question["stem"]
|
| 117 |
-
if split == "test":
|
| 118 |
-
answerkey = ""
|
| 119 |
-
else:
|
| 120 |
-
answerkey = data["answerKey"]
|
| 121 |
-
|
| 122 |
-
yield id_, {
|
| 123 |
-
"answerKey": answerkey,
|
| 124 |
-
"question": stem,
|
| 125 |
-
"choices": {"label": labels, "text": texts},
|
| 126 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|