CogComp/mc_taco
MC-TACO (Multiple Choice TemporAl COmmonsense) is a dataset of 13k question-answer pairs that require temporal commonsense comprehension. A system receives a sentence providing context information, a question designed to require temporal commonsense knowledge, and multiple candidate answers. More than one candidate answer can be plausible. The task is framed as binary classification: givent he context, the question, and the candidate answer, the task is to determine whether the candidate answer is plausible ("yes") or not ("no").
32.6k
1# coding=utf-82# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.3#4# Licensed under the Apache License, Version 2.0 (the "License");5# you may not use this file except in compliance with the License.6# You may obtain a copy of the License at7#8# http://www.apache.org/licenses/LICENSE-2.09#10# Unless required by applicable law or agreed to in writing, software11# distributed under the License is distributed on an "AS IS" BASIS,12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13# See the License for the specific language governing permissions and14# limitations under the License.15"""MC-TACO Dataset."""16 17 18import csv19 20import datasets21 22 23_CITATION = """\24@inproceedings{ZKNR19,25 author = {Ben Zhou, Daniel Khashabi, Qiang Ning and Dan Roth},26 title = {“Going on a vacation” takes longer than “Going for a walk”: A Study of Temporal Commonsense Understanding },27 booktitle = {EMNLP},28 year = {2019},29}30"""31 32_DESCRIPTION = """\33MC-TACO (Multiple Choice TemporAl COmmonsense) is a dataset of 13k question-answer34pairs that require temporal commonsense comprehension. A system receives a sentence35providing context information, a question designed to require temporal commonsense36knowledge, and multiple candidate answers. More than one candidate answer can be plausible.37 38The task is framed as binary classification: givent he context, the question,39and the candidate answer, the task is to determine whether the candidate40answer is plausible ("yes") or not ("no")."""41 42_LICENSE = "Unknown"43 44_URLs = {45 "dev": "https://raw.githubusercontent.com/CogComp/MCTACO/master/dataset/dev_3783.tsv",46 "test": "https://raw.githubusercontent.com/CogComp/MCTACO/master/dataset/test_9442.tsv",47}48 49 50class McTaco(datasets.GeneratorBasedBuilder):51 """MC-TACO Dataset: temporal commonsense knowledge."""52 53 VERSION = datasets.Version("1.1.0")54 55 BUILDER_CONFIGS = [56 datasets.BuilderConfig(57 name="plain_text",58 description="Plain text",59 version=VERSION,60 ),61 ]62 63 def _info(self):64 return datasets.DatasetInfo(65 description=_DESCRIPTION,66 features=datasets.Features(67 {68 "sentence": datasets.Value("string"),69 "question": datasets.Value("string"),70 "answer": datasets.Value("string"),71 "label": datasets.ClassLabel(names=["no", "yes"]),72 "category": datasets.ClassLabel(73 names=["Event Duration", "Event Ordering", "Frequency", "Typical Time", "Stationarity"]74 ),75 }76 ),77 supervised_keys=None,78 homepage="https://cogcomp.seas.upenn.edu/page/resource_view/125",79 license=_LICENSE,80 citation=_CITATION,81 )82 83 def _split_generators(self, dl_manager):84 """Returns SplitGenerators."""85 data_dir = dl_manager.download_and_extract(_URLs)86 return [87 datasets.SplitGenerator(88 name=datasets.Split.TEST,89 gen_kwargs={90 "filepath": data_dir["test"],91 },92 ),93 datasets.SplitGenerator(94 name=datasets.Split.VALIDATION,95 gen_kwargs={96 "filepath": data_dir["dev"],97 },98 ),99 ]100 101 def _generate_examples(self, filepath):102 """Yields examples."""103 with open(filepath, encoding="utf-8") as csv_file:104 csv_reader = csv.reader(105 csv_file,106 delimiter="\t",107 )108 for id_, row in enumerate(csv_reader):109 yield id_, {110 "sentence": row[0],111 "question": row[1],112 "answer": row[2],113 "label": row[3],114 "category": row[4],115 }116 