# 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. """Discourse marker/connective prediction as multiple choice questions based on the Discovery dataset""" import csv import json import os import datasets _CITATION = """\ @inproceedings{sileo-etal-2019-mining, title = "Mining Discourse Markers for Unsupervised Sentence Representation Learning", author = "Sileo, Damien and Van De Cruys, Tim and Pradel, Camille and Muller, Philippe", booktitle = "Proceedings of the 2019 Conference of the North {A}merican Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers)", month = jun, year = "2019", address = "Minneapolis, Minnesota", publisher = "Association for Computational Linguistics", url = "https://aclanthology.org/N19-1351", doi = "10.18653/v1/N19-1351", pages = "3477--3486", abstract = "Current state of the art systems in NLP heavily rely on manually annotated datasets, which are expensive to construct. Very little work adequately exploits unannotated data {--} such as discourse markers between sentences {--} mainly because of data sparseness and ineffective extraction methods. In the present work, we propose a method to automatically discover sentence pairs with relevant discourse markers, and apply it to massive amounts of data. Our resulting dataset contains 174 discourse markers with at least 10k examples each, even for rare markers such as {``}coincidentally{''} or {``}amazingly{''}. We use the resulting data as supervision for learning transferable sentence embeddings. In addition, we show that even though sentence representation learning through prediction of discourse marker yields state of the art results across different transfer tasks, it{'}s not clear that our models made use of the semantic relation between sentences, thus leaving room for further improvements.", } """ _DESCRIPTION = """\ Discourse marker/connective prediction as multiple choice questions based on the Discovery dataset """ _HOMEPAGE = "" _LICENSE = "apache-2.0" _URL = "https://sileod.s3.eu-west-3.amazonaws.com/huggingface/discourse_marker_mcqa_test.json" class DiscoveryQA(datasets.GeneratorBasedBuilder): VERSION = datasets.Version("1.1.0") def _info(self): features = datasets.Features( { "context": datasets.Value("string"), "answer_0": datasets.Value("string"), "answer_1": datasets.Value("string"), "answer_2": datasets.Value("string"), "answer_3": datasets.Value("string"), "answer_4": datasets.Value("string"), "answer_5": datasets.Value("string"), "answer_6": datasets.Value("string"), "answer_7": datasets.Value("string"), "answer_8": datasets.Value("string"), "answer_9": datasets.Value("string"), "label": datasets.Value("int32") } ) return datasets.DatasetInfo( description=_DESCRIPTION, features=features, # Here we define them above because they are different between the two configurations homepage=_HOMEPAGE, license=_LICENSE, citation=_CITATION, ) def _split_generators(self, dl_manager): data_dir = dl_manager.download(_URL) return [ datasets.SplitGenerator( name=datasets.Split.TEST, # These kwargs will be passed to _generate_examples 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): yield key, dict(json.loads(row))