|
import datasets |
|
import json |
|
import os |
|
|
|
citation=''' |
|
@article{han2022folio, |
|
title={FOLIO: Natural Language Reasoning with First-Order Logic}, |
|
author = {Han, Simeng and Schoelkopf, Hailey and Zhao, Yilun and Qi, Zhenting and Riddell, Martin and Benson, Luke and Sun, Lucy and Zubova, Ekaterina and Qiao, Yujie and Burtell, Matthew and Peng, David and Fan, Jonathan and Liu, Yixin and Wong, Brian and Sailor, Malcolm and Ni, Ansong and Nan, Linyong and Kasai, Jungo and Yu, Tao and Zhang, Rui and Joty, Shafiq and Fabbri, Alexander R. and Kryscinski, Wojciech and Lin, Xi Victoria and Xiong, Caiming and Radev, Dragomir}, |
|
journal={arXiv preprint arXiv:2209.00840}, |
|
url = {https://arxiv.org/abs/2209.00840}, |
|
year={2022} |
|
} |
|
''' |
|
|
|
class FolioConfig(datasets.BuilderConfig): |
|
citation=citation |
|
|
|
files = ["folio-validation.jsonl"] |
|
|
|
_URLs = {f:f"https://huggingface.co/datasets/benlipkin/folio/resolve/main/{f}" for f in files} |
|
|
|
class Folio(datasets.GeneratorBasedBuilder): |
|
BUILDER_CONFIGS = [ |
|
FolioConfig( |
|
name='.'.join(n.split('.')[:-1]), |
|
data_dir=n |
|
) for n in files |
|
] |
|
|
|
|
|
def _split_generators(self, dl_manager: datasets.DownloadManager): |
|
data_file = dl_manager.download(_URLs) |
|
path=data_file[self.config.data_dir] |
|
pval=os.path.join(path,"folio-validation.jsonl") |
|
|
|
return [ |
|
datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": pval}), |
|
] |
|
|
|
def _info(self): |
|
return datasets.DatasetInfo() |
|
|
|
def _generate_examples(self, filepath): |
|
cols=["premises", "premises-FOL", "conclusion", "conclusion-FOL", "label"] |
|
"""Yields examples.""" |
|
with open(filepath, "r", encoding="utf-8") as f: |
|
for id_, line in enumerate(f): |
|
line_dict = json.loads(line) |
|
line_dict={k:v for k,v in line_dict.items() if k in cols} |
|
yield id_, line_dict |
|
|