# coding=utf-8 # 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. """TODO: Add a description here.""" import json import csv import datasets # TODO: Add BibTeX citation # Find for instance the citation on arxiv or on the dataset repo/website _CITATION = """\ """ # TODO: Add description of the dataset here # You can copy an official description _DESCRIPTION = """\ The SQuADID-NLI dataset is derived from the SQuADID question answering dataset, utilizing named entity recognition (NER), chunking tags, Regex, and embedding similarity techniques to determine its contradiction sets. Collected through this process, the dataset comprises various columns beyond premise, hypothesis, and label, including properties aligned with NER and chunking tags. This dataset is designed to facilitate Natural Language Inference (NLI) tasks and contains information extracted from diverse sources to provide comprehensive coverage. Each data instance encapsulates premise, hypothesis, label, and additional properties pertinent to NLI evaluation. """ # TODO: Add a link to an official homepage for the dataset here _HOMEPAGE = "https://huggingface.co/datasets/muhammadravi251001/squadid-nli" # TODO: Add the licence for the dataset here if you can find it _LICENSE = """ """ _TRAIN_DOWNLOAD_URL = "https://huggingface.co/datasets/muhammadravi251001/squadid-nli/resolve/main/squad-id_nli_train_df.csv?download=true" _VALID_DOWNLOAD_URL = "https://huggingface.co/datasets/muhammadravi251001/squadid-nli/resolve/main/squad-id_nli_val_df.csv?download=true" _TEST_DOWNLOAD_URL = "https://huggingface.co/datasets/muhammadravi251001/squadid-nli/resolve/main/squad-id_nli_test_df.csv?download=true" class SQuADIDNLIConfig(datasets.BuilderConfig): """BuilderConfig for SQuADID-NLI Config""" def __init__(self, **kwargs): """BuilderConfig for SQuADID-NLI Config. Args: **kwargs: keyword arguments forwarded to super. """ super(SQuADIDNLIConfig, self).__init__(**kwargs) class SQuADIDNLI(datasets.GeneratorBasedBuilder): """SQuADID-NLI dataset -- Syntethic NLI dataset derived from QA dataset utilizing named entity recognition (NER), chunking tags, Regex, and embedding similarity techniques to determine its contradiction sets""" BUILDER_CONFIGS = [ SQuADIDNLIConfig( name="squadid-nli", version=datasets.Version("1.1.0"), description="SQuADID-NLI: Syntethic NLI dataset derived from QA dataset utilizing named entity recognition (NER), chunking tags, Regex, and embedding similarity techniques to determine its contradiction sets", ), ] def _info(self): return datasets.DatasetInfo( description=_DESCRIPTION, features=datasets.Features( { "premise": datasets.Value("string"), "hypothesis": datasets.Value("string"), "label": datasets.ClassLabel(names=["entailment", "neutral", "contradiction"]), } ), supervised_keys=None, homepage=_HOMEPAGE, license=_LICENSE, citation=_CITATION, ) def _split_generators(self, dl_manager): """Returns SplitGenerators.""" train_path = dl_manager.download_and_extract(_TRAIN_DOWNLOAD_URL) valid_path = dl_manager.download_and_extract(_VALID_DOWNLOAD_URL) test_path = dl_manager.download_and_extract(_TEST_DOWNLOAD_URL) return [ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": train_path}), datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": valid_path}), datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": test_path}), ] def _generate_examples(self, filepath): """Yields examples.""" with open(filepath, encoding="utf-8") as csv_file: csv_reader = csv.DictReader(csv_file) for id_, row in enumerate(csv_reader): yield id_, { "premise": row["premise"], "hypothesis": row["hypothesis"], "label": row["label"] }