Fin-Fact / Fin-Fact.py
amanrangapur's picture
Update Fin-Fact.py
bb44342 verified
raw
history blame
2.58 kB
"""Fin-Fact dataset."""
import json
import datasets
_CITATION = """\
@misc{rangapur2023finfact,
title={Fin-Fact: A Benchmark Dataset for Multimodal Financial Fact Checking and Explanation Generation},
author={Aman Rangapur and Haoran Wang and Kai Shu},
year={2023},
eprint={2309.08793},
archivePrefix={arXiv},
primaryClass={cs.AI}
}
"""
_DESCRIPTION = """\
Fin-Fact is a comprehensive dataset designed specifically for financial fact-checking and explanation generation.
The dataset consists of 3121 claims spanning multiple financial sectors.
"""
_HOMEPAGE = "https://github.com/IIT-DM/Fin-Fact"
_LICENSE = "Apache 2.0"
_URL = "https://huggingface.co/datasets/amanrangapur/Fin-Fact/resolve/main/finfact.json"
class FinFact(datasets.GeneratorBasedBuilder):
"""Fin-Fact dataset for financial fact-checking and text generation."""
VERSION = datasets.Version("1.0.0")
BUILDER_CONFIGS = [
datasets.BuilderConfig(
name="generation",
version=VERSION,
description="The Fin-Fact dataset for financial fact-checking and text generation",
),
]
DEFAULT_CONFIG_NAME = "generation"
def _info(self):
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=datasets.Features(
{
"url": datasets.Value("string"),
"claim": datasets.Value("string"),
"author": datasets.Value("string"),
"posted": datasets.Value("string"),
"label": datasets.Value("string"),
}
),
supervised_keys=None,
homepage=_HOMEPAGE,
license=_LICENSE,
citation=_CITATION,
)
def _split_generators(self, dl_manager):
downloaded_file = dl_manager.download(_URL)
return [
datasets.SplitGenerator(
name=datasets.Split.TRAIN,
gen_kwargs={
"filepath": downloaded_file,
},
),
]
def _generate_examples(self, filepath):
with open(filepath, encoding="utf-8") as f:
data = json.load(f)
for id_, row in enumerate(data):
yield id_, {
"url": row.get("url", ""),
"claim": row.get("claim", ""),
"author": row.get("author", ""),
"posted": row.get("posted", ""),
"label": row.get("label", ""),
}