|
"""TODO(reclor): Add a description here.""" |
|
|
|
|
|
import json |
|
import os |
|
|
|
import datasets |
|
|
|
|
|
|
|
_CITATION = """\ |
|
@inproceedings{yu2020reclor, |
|
author = {Yu, Weihao and Jiang, Zihang and Dong, Yanfei and Feng, Jiashi}, |
|
title = {ReClor: A Reading Comprehension Dataset Requiring Logical Reasoning}, |
|
booktitle = {International Conference on Learning Representations (ICLR)}, |
|
month = {April}, |
|
year = {2020} |
|
} |
|
|
|
""" |
|
|
|
|
|
_DESCRIPTION = """\ |
|
Logical reasoning is an important ability to examine, analyze, and critically evaluate arguments as they occur in ordinary |
|
language as the definition from LSAC. ReClor is a dataset extracted from logical reasoning questions of standardized graduate |
|
admission examinations. Empirical results show that the state-of-the-art models struggle on ReClor with poor performance |
|
indicating more research is needed to essentially enhance the logical reasoning ability of current models. We hope this |
|
dataset could help push Machine Reading Comprehension (MRC) towards more complicated reasonin |
|
""" |
|
|
|
|
|
class Reclor(datasets.GeneratorBasedBuilder): |
|
"""TODO(reclor): Short description of my dataset.""" |
|
|
|
|
|
VERSION = datasets.Version("0.1.0") |
|
|
|
@property |
|
def manual_download_instructions(self): |
|
return """\ |
|
to use ReClor you need to download it manually. Please go to its homepage (http://whyu.me/reclor/) fill the google |
|
form and you will receive a download link and a password to extract it.Please extract all files in one folder and use the path folder in datasets.load_dataset('reclor', data_dir='path/to/folder/folder_name') |
|
""" |
|
|
|
def _info(self): |
|
|
|
return datasets.DatasetInfo( |
|
|
|
description=_DESCRIPTION, |
|
|
|
features=datasets.Features( |
|
{ |
|
|
|
"context": datasets.Value("string"), |
|
"question": datasets.Value("string"), |
|
"answers": datasets.features.Sequence(datasets.Value("string")), |
|
"label": datasets.Value("string"), |
|
"id_string": datasets.Value("string"), |
|
} |
|
), |
|
|
|
|
|
|
|
supervised_keys=None, |
|
|
|
homepage="http://whyu.me/reclor/", |
|
citation=_CITATION, |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
"""Returns SplitGenerators.""" |
|
|
|
|
|
|
|
data_dir = os.path.abspath(os.path.expanduser(dl_manager.manual_dir)) |
|
|
|
if not os.path.exists(data_dir): |
|
raise FileNotFoundError( |
|
f"{data_dir} does not exist. Make sure you insert a manual dir via `datasets.load_dataset('wikihow', data_dir=...)` that includes files unzipped from the reclor zip. Manual download instructions: {self.manual_download_instructions}" |
|
) |
|
return [ |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TRAIN, |
|
|
|
gen_kwargs={"filepath": os.path.join(data_dir, "train.json")}, |
|
), |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TEST, |
|
|
|
gen_kwargs={"filepath": os.path.join(data_dir, "test.json")}, |
|
), |
|
datasets.SplitGenerator( |
|
name=datasets.Split.VALIDATION, |
|
|
|
gen_kwargs={"filepath": os.path.join(data_dir, "val.json")}, |
|
), |
|
] |
|
|
|
def _generate_examples(self, filepath): |
|
"""Yields examples.""" |
|
|
|
with open(filepath, encoding="utf-8") as f: |
|
data = json.load(f) |
|
for id_, row in enumerate(data): |
|
yield id_, { |
|
"context": row["context"], |
|
"question": row["question"], |
|
"answers": row["answers"], |
|
"label": str(row.get("label", "")), |
|
"id_string": row["id_string"], |
|
} |
|
|