File size: 8,344 Bytes
e508d32 23e9417 |
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 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
"""Fin-Fact dataset."""
import json
import os
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 = """\
Welcome to the Fin-Fact repository! 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 = """\
MIT License
Copyright (c) 2023 Illinois Tech Data Mining Lab
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""
_URL = "https://huggingface.co/datasets/amanrangapur/Fin-Fact/resolve/main/finfact.json"
# class FinFact(datasets.GeneratorBasedBuilder):
# VERSION = datasets.Version("1.0.0")
# BUILDER_CONFIGS = [
# datasets.BuilderConfig(
# name="finfact",
# version=datasets.Version("1.0.0")
# )
# ]
# 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"),
# # "justification": datasets.Value("string"),
# # "issues": datasets.Value("string"),
# # "evidence": datasets.Value("string"),
# # "summary": datasets.Value("string"),
# # "label": datasets.Value("string"),
# }
# ),
# supervised_keys=None,
# homepage=_HOMEPAGE,
# citation=_CITATION,
# license=_LICENSE,
# version=self.VERSION,
# )
# def _split_generators(self, dl_manager):
# """Returns SplitGenerators."""
# # lang = str(self.config.name)
# url = _URL.format(self.VERSION.version_str[:-2])
# data_dir = dl_manager.download_and_extract(url)
# return [
# datasets.SplitGenerator(
# name=datasets.Split.TRAIN,
# gen_kwargs={
# "filepath": os.path.join(data_dir),
# },
# )
# ]
# def _generate_examples(self, filepath):
# """Yields examples as (key, example) tuples."""
# with open(filepath, encoding="utf-8") as f:
# for idx_, row in enumerate(f):
# data = json.loads(row)
# yield idx_, {
# "url": data["url"],
# "claim": data["claim"],
# "author": data["author"],
# "posted": data["posted"],
# # "sci_digest": data["sci_digest"],
# # "justification": data["justification"],
# # "issues": data["issues"],
# # "image_data": data["image_data"],
# # "evidence": data["evidence"],
# # "label": data["label"],
# }
class Finfact(datasets.BuilderConfig):
"""BuilderConfig for Fin-Fact"""
def __init__(self, **kwargs):
"""
Args:
**kwargs: keyword arguments forwarded to super.
"""
super(Finfact, self).__init__(version=datasets.Version("1.0.0", ""), **kwargs)
class PubmedQA(datasets.GeneratorBasedBuilder):
VERSION = datasets.Version("1.0.0")
BUILDER_CONFIGS = [
datasets.BuilderConfig(
name="finfact",
version=datasets.Version("1.0.0")
)
]
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"),
}
),
supervised_keys=None,
homepage=_HOMEPAGE,
license=_LICENSE,
citation=_CITATION,
)
def _split_generators(self, dl_manager):
downloaded_files = dl_manager.download_and_extract(_URL)
return [
datasets.SplitGenerator(
name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files}
)
]
# def _split_generators(self, dl_manager):
# """Returns SplitGenerators."""
# # lang = str(self.config.name)
# url = _URL.format(self.VERSION.version_str[:-2])
# data_dir = dl_manager.download_and_extract(url)
# return [
# datasets.SplitGenerator(
# name=datasets.Split.TRAIN,
# gen_kwargs={
# "filepath": os.path.join(data_dir),
# },
# )
# ]
# def _generate_examples(self, filepath):
# """Yields examples as (key, example) tuples."""
# with open(filepath, encoding="utf-8") as f:
# for idx_, row in enumerate(f):
# data = json.loads(row)
# yield idx_, {
# "url": data["url"],
# "claim": data["claim"],
# "author": data["author"],
# "posted": data["posted"],
# # "sci_digest": data["sci_digest"],
# # "justification": data["justification"],
# # "issues": data["issues"],
# # "image_data": data["image_data"],
# # "evidence": data["evidence"],
# # "label": data["label"],
# }
# def _generate_examples(self, filepath):
# with open(filepath, encoding="utf-8") as f:
# data = json.load(f)
# print(data)
# for id_, row in enumerate(data):
# print("id_", id_)
# print("row ", row)
# yield id_, {
# "url": data[row]["url"],
# "claim": data[row]["claim"],
# "author": data[row]["author"],
# "posted": data[row]["posted"],
# # "context": {
# # "contexts": data[row]["CONTEXTS"],
# # "labels": data[row]["LABELS"],
# # "meshes": data[row]["MESHES"],
# # },
# # "long_answer": data[row]["LONG_ANSWER"],
# # "final_decision": data[row]["final_decision"],
# }
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["url"],
"claim": row["claim"],
"author": row["author"],
"posted": row["posted"],
}
|