Datasets:

Languages:
Spanish
License:
File size: 3,315 Bytes
0aadd47
 
 
51f8218
0aadd47
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2b9e296
 
 
0aadd47
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
02d6b0a
0aadd47
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2b9e296
fe48c03
efec165
 
 
 
 
 
 
0aadd47
 
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
# Loading script for the TECA dataset.
import json
import datasets
import pandas as pd

logger = datasets.logging.get_logger(__name__)

_CITATION = """
            ADD CITATION
            """

_DESCRIPTION = """
               professional translation into Spanish of Winograd NLI dataset as published in GLUE Benchmark.
               The Winograd NLI dataset presents 855 sentence pairs, 
               in which the first sentence contains an ambiguity and the second one a possible interpretation of it. 
               The label indicates if the interpretation is correct (1) or not (0).
               """

_HOMEPAGE = """https://cs.nyu.edu/~davise/papers/WinogradSchemas/WS.html"""

# TODO: upload datasets to github
_URL = "./"
_TRAINING_FILE = "wnli-train-es.csv"
_DEV_FILE = "wnli-dev-es.csv"
_TEST_FILE = "wnli-test-shuffled-es.csv"


class WinogradConfig(datasets.BuilderConfig):
    """ Builder config for the Winograd-CA dataset """

    def __init__(self, **kwargs):
        """BuilderConfig for Winograd-CA.
        Args:
          **kwargs: keyword arguments forwarded to super.
        """
        super(WinogradConfig, self).__init__(**kwargs)


class Winograd(datasets.GeneratorBasedBuilder):
    """ Winograd Dataset """

    BUILDER_CONFIGS = [
        WinogradConfig(
            name="winograd",
            version=datasets.Version("1.0.0"),
            description="Winograd dataset",
        ),
    ]
    
    def _info(self):
        return datasets.DatasetInfo(
            description=_DESCRIPTION,
            features=datasets.Features(
                {
                    "sentence1": datasets.Value("string"),
                    "sentence2": datasets.Value("string"),
                    "label": datasets.features.ClassLabel
                        (names=
                    [
                        "not_entailment",
                        "entailment"
                    ]
                    ),
                }
            ),
            homepage=_HOMEPAGE,
            citation=_CITATION,
        )

    def _split_generators(self, dl_manager):
        """Returns SplitGenerators."""
        urls_to_download = {
            "train": f"{_URL}{_TRAINING_FILE}",
            "dev": f"{_URL}{_DEV_FILE}",
            "test": f"{_URL}{_TEST_FILE}",
        }
        downloaded_files = dl_manager.download_and_extract(urls_to_download)

        return [
            datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}),
            datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": downloaded_files["dev"]}),
            datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": downloaded_files["test"]}),
        ]

    def _generate_examples(self, filepath):
        """This function returns the examples in the raw (text) form."""
        logger.info("generating examples from = %s", filepath)
        df = pd.read_csv(filepath)
        header = df.keys()
        process_label = {0: "not_entailment", 1: "entailment", -1:-1}
        for id_, (ref, sentence1, sentence2, score) in df.iterrows():
            yield id_, {
                "sentence1": sentence1,
                "sentence2": sentence2,
                "label": process_label[int(score)],
            }