Datasets:
Tasks:
Text Classification
Modalities:
Text
Formats:
parquet
Sub-tasks:
natural-language-inference
Languages:
English
Size:
100K - 1M
License:
File size: 2,317 Bytes
89c050a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
import datasets
import json
import os
citation='''
@inproceedings{rudinger-etal-2020-thinking,
title = "Thinking Like a Skeptic: Defeasible Inference in Natural Language",
author = "Rudinger, Rachel and
Shwartz, Vered and
Hwang, Jena D. and
Bhagavatula, Chandra and
Forbes, Maxwell and
Le Bras, Ronan and
Smith, Noah A. and
Choi, Yejin",
booktitle = "Findings of the Association for Computational Linguistics: EMNLP 2020",
month = nov,
year = "2020",
address = "Online",
publisher = "Association for Computational Linguistics",
url = "https://www.aclweb.org/anthology/2020.findings-emnlp.418",
doi = "10.18653/v1/2020.findings-emnlp.418",
pages = "4661--4675"
}
'''
class DefeasibleNLIConfig(datasets.BuilderConfig):
citation=citation
configs = ['atomic','snli','social']
splits=['train', 'test', 'dev']
_URLs = {(f,s):f"https://huggingface.co/datasets/metaeval/defeasible-nli/resolve/main/{f}_{s}.jsonl" for f in configs for s in splits}
class DefeasibleNLI(datasets.GeneratorBasedBuilder):
BUILDER_CONFIGS = [
DefeasibleNLIConfig(
name=n,
data_dir=n
) for n in configs
]
def _split_generators(self, dl_manager: datasets.DownloadManager):
path = lambda split: dl_manager.download(_URLs[self.config.name,split])
return [ datasets.SplitGenerator(name=name, gen_kwargs={'path':path(split),'split':split})
for name,split in zip([datasets.Split.TRAIN,datasets.Split.VALIDATION,datasets.Split.TEST],
['train','dev','test'])]
def _info(self):
return datasets.DatasetInfo()
def _generate_examples(self,path,split):
"""Yields examples."""
with open(path, "r", encoding="utf-8") as f:
for id_, line in enumerate(f):
line_dict = json.loads(line)
if not line_dict['UpdateTypeImpossible']:
fields = ["Premise","Hypothesis","Update","UpdateType"]#,"UpdateTypeImpossible","UpdateTypeImpossibleReason"]
line_dict = {k:v for k,v in line_dict.items() if k in fields}
yield id_, line_dict
|