File size: 2,579 Bytes
ac8e140 |
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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
"""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", ""),
} |