# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import json import datasets # TODO: Add BibTeX citation # Find for instance the citation on arxiv or on the dataset repo/website _CITATION = """\ @InProceedings{huggingface:dataset, title = {A great new dataset}, author={huggingface, Inc. }, year={2020} } """ # You can copy an official description _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( # This is the description that will appear on the datasets page. description=_DESCRIPTION, # This defines the different columns of the dataset and their types features=features, # Here we define them above because they are different between the two configurations # If there's a common (input, target) tuple from the features, uncomment supervised_keys line below and # specify them. They'll be used if as_supervised=True in builder.as_dataset. # supervised_keys=("sentence", "label"), # Homepage of the dataset for documentation homepage=_HOMEPAGE, # License for the dataset if available license=_LICENSE, # Citation for the dataset 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, # These kwargs will be passed to _generate_examples gen_kwargs={ "filepath": data_dir, "split": "test" }, ), ] # method parameters are unpacked from `gen_kwargs` as given in `_split_generators` 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