Datasets:

Modalities:
Text
Libraries:
Datasets
License:
UKP_ASPECT / UKP_ASPECT.py
ukp-data-admin's picture
remove subsplit
6049f3e
# 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 description
"""TexPrax: Data collected during the project https://texprax.de/ """
import csv
import os
import ast
#import json
import datasets
# TODO: Add citation
_CITATION = """\
@inproceedings{reimers2019classification,
title={Classification and Clustering of Arguments with Contextualized Word Embeddings},
author={Reimers, Nils and Schiller, Benjamin and Beck, Tilman and Daxenberger, Johannes and Stab, Christian and Gurevych, Iryna},
booktitle={Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics},
pages={567--578},
year={2019}
}
"""
# TODO: Add description
_DESCRIPTION = """\
The UKP ASPECT Corpus includes 3,595 sentence pairs over 28 controversial topics. The sentences were crawled from a large web crawl and identified as arguments for a given topic using the ArgumenText system. The sampling and matching of the sentence pairs is described in the paper. Then, the argument similarity annotation was done via crowdsourcing. Each crowd worker could choose from four annotation options (the exact guidelines are provided in the Appendix of the paper).
"""
# TODO: Add link
_HOMEPAGE = "https://tudatalib.ulb.tu-darmstadt.de/handle/tudatalib/1998"
# TODO: Add license
_LICENSE = "Creative Commons Attribution-NonCommercial 3.0"
# TODO: Add tudatalib urls here!
_URL = "https://tudatalib.ulb.tu-darmstadt.de/bitstream/handle/tudatalib/1998/UKP_ASPECT.zip?sequence=1&isAllowed=y"
class UKPAspectConfig(datasets.BuilderConfig):
"""BuilderConfig for UKP ASPECT."""
def __init__(self, features, data_url, citation, url, label_classes=("False", "True"), **kwargs):
super(UKPAspectConfig, self).__init__(**kwargs)
class UKPAspectDataset(datasets.GeneratorBasedBuilder):
"""3,595 sentence pairs over 28 controversial topics. The sentences were crawled from a large web crawl and identified as arguments for a given topic using the ArgumenText system. The sampling and matching of the sentence pairs is described in the paper. Then, the argument similarity annotation was done via crowdsourcing. Each crowd worker could choose from four annotation options (the exact guidelines are provided in the Appendix of the paper)."""
VERSION = datasets.Version("1.1.0")
BUILDER_CONFIGS = [
datasets.BuilderConfig(name="standard", version=VERSION, description="Sentence pairs annotated with argument similarity")
]
DEFAULT_CONFIG_NAME = "standard" # It's not mandatory to have a default configuration. Just use one if it make sense.
def _info(self):
if self.config.name == "standard": # This is the name of the configuration selected in BUILDER_CONFIGS above
features = datasets.Features(
{
# Note: ID consists of <dialog-id_sentence-id_turn-id>
"topic": datasets.Value("string"),
"sentence_1": datasets.Value("string"),
"sentence_2": datasets.Value("string"),
"label": datasets.features.ClassLabel(
names=[
"NS",
"SS",
"DTORCD",
"HS",
]),
# These are the features of your dataset like images, labels ...
}
)
else:
raise ValueError(f'The only available config is "standard", but "{self.config.name}" was given')
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):
# If several configurations are possible (listed in BUILDER_CONFIGS), the configuration selected by the user is in self.config.name
# TODO: Add your splits. .zip files will automatically be extracted, so you don't have to worry about them.
if self.config.name == "standard":
urls = _URL
data_dir = dl_manager.download_and_extract(urls)
return [
datasets.SplitGenerator(
name=datasets.Split.TRAIN,
# These kwargs will be passed to _generate_examples
gen_kwargs={
"filepath": os.path.join(data_dir, "UKP_ASPECT.tsv"),
"split": "train",
},
)
]
else:
raise ValueError(f'The only available config is "standard", but "{self.config.name}" was given')
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
def _generate_examples(self, filepath, split):
# TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
# The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
with open(filepath, encoding="utf-8") as f:
creader = csv.reader(f, delimiter='\t', quotechar='"')
next(creader) # skip header
for key, row in enumerate(creader):
# TODO: Use the same keys here as in the datasets.Features of _info(self)
if self.config.name == "standard":
topic, sentence_1, sentence_2, label = row
# Yields examples as (key, example) tuples
yield key, {
"topic": topic,
"sentence_1": sentence_1,
"sentence_2": sentence_2,
"label": label,
}
else:
raise ValueError(f'The only available config is "standard", but "{self.config.name}" was given')