Datasets:

Modalities:
Text
Libraries:
Datasets
License:
File size: 7,254 Bytes
3075d10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# 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",
                            ]),
                    "subsplit": datasets.Value("string"),
                    # 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.ALL,
                    # These kwargs will be passed to _generate_examples
                    gen_kwargs={
                        "filepath": os.path.join(data_dir, "UKP_ASPECT.tsv"),
                        "split": "all",
                    },
                )
            ]
        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')