|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import json |
|
import datasets |
|
|
|
|
|
|
|
|
|
_CITATION = """\ |
|
@InProceedings{huggingface:dataset, |
|
title = {A great new dataset}, |
|
author={huggingface, Inc. |
|
}, |
|
year={2020} |
|
} |
|
""" |
|
|
|
|
|
_DESCRIPTION = """\ |
|
SufficientFacts is a diagnostic test dataset for fact checking with insufficient evidence. |
|
""" |
|
|
|
_HOMEPAGE = "https://github.com/copenlu/sufficient_facts" |
|
|
|
_LICENSE = """MIT License |
|
Copyright (c) 2022 CopeNLU |
|
|
|
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.""" |
|
|
|
_URLS = { |
|
"fever": "https://raw.githubusercontent.com/copenlu/sufficient_facts/master/data/sufficient_facts/fever_sufficient_facts.jsonl", |
|
"vitaminc": "https://raw.githubusercontent.com/copenlu/sufficient_facts/master/data/sufficient_facts/vitaminc_sufficient_facts.jsonl", |
|
"hover": "https://raw.githubusercontent.com/copenlu/sufficient_facts/master/data/sufficient_facts/hover_sufficient_facts.jsonl", |
|
} |
|
|
|
|
|
class SufficientFacts(datasets.GeneratorBasedBuilder): |
|
"""SufficientFacts is a diagnostic test dataset for fact checking with insufficient evidence.""" |
|
|
|
VERSION = datasets.Version("1.1.0") |
|
|
|
BUILDER_CONFIGS = [ |
|
datasets.BuilderConfig(name="fever", version=VERSION, description="FEVER test set."), |
|
datasets.BuilderConfig(name="hover", version=VERSION, description="HoVer test set."), |
|
datasets.BuilderConfig(name="vitaminc", version=VERSION, description="VitaminC test set."), |
|
] |
|
|
|
def _info(self): |
|
features = datasets.Features( |
|
{ |
|
"claim": datasets.Value("string"), |
|
"evidence": datasets.features.Sequence(datasets.features.Sequence(datasets.Value("string"))), |
|
"label_before": datasets.Value("string"), |
|
"label_after": datasets.Value("string"), |
|
"type": datasets.Value("string"), |
|
"removed": datasets.features.Sequence(datasets.Value("string")), |
|
"text_orig": datasets.Value("string"), |
|
"agreement": datasets.Value("string") |
|
} |
|
) |
|
|
|
return datasets.DatasetInfo( |
|
|
|
description=_DESCRIPTION, |
|
|
|
features=features, |
|
|
|
|
|
|
|
|
|
homepage=_HOMEPAGE, |
|
|
|
license=_LICENSE, |
|
|
|
citation=_CITATION, |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
urls = _URLS[self.config.name] |
|
data_dir = dl_manager.download_and_extract(urls) |
|
return [ |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TEST, |
|
|
|
gen_kwargs={ |
|
"filepath": data_dir, |
|
"split": "test" |
|
}, |
|
), |
|
] |
|
|
|
|
|
def _generate_examples(self, filepath, split): |
|
with open(filepath, encoding="utf-8") as f: |
|
for key, row in enumerate(f): |
|
data = json.loads(row) |
|
yield key, data |