Datasets:
mteb
/

Modalities:
Text
Formats:
json
Libraries:
Datasets
pandas
File size: 3,337 Bytes
3d4f993
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c3a9536
3d4f993
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
570b1ab
 
 
 
3d4f993
570b1ab
3d4f993
 
 
570b1ab
3d4f993
 
 
 
 
 
 
 
 
570b1ab
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
import json
import datasets
import os

_CITATION = """\
"""

_LICENSE = """\
"""

_DESCRIPTION = """\
SemEval 2022 Task 8: Multilingual News Article Similarity
"""

_LANGUAGES_TRAIN = {
    "en": "en",
    "de": "de",
    "es": "es",
    "pl": "pl",
    "tr": "tr",
    "fr": "fr",
    "ar": "ar",
    "de-en": "de-en",
}
_LANGUAGES_TEST = {
    "en": "en",
    "de": "de",
    "es": "es",
    "pl": "pl",
    "tr": "tr",
    "ar": "ar",
    "ru": "ru",
    "zh": "zh",
    "fr": "fr",
    "de-en": "de-en",
    "es-en": "es-en",
    "it": "it",
    "pl-en": "pl-en",
    "zh-en": "zh-en",
    "es-it": "es-it",
    "de-fr": "de-fr",
    "de-pl": "de-pl",
    "fr-pl": "fr-pl",
}
_LANGUAGES = {**_LANGUAGES_TRAIN, **_LANGUAGES_TEST}

_ALL_LANGUAGES = "all_languages"
_HOMEPAGE_URL = "https://competitions.codalab.org/competitions/33835"
_DOWNLOAD_URL = "{lang}/{split}.jsonl"
_VERSION = "1.0.0"


class STS22Task8Config(datasets.BuilderConfig):
    """BuilderConfig for STS22Task8Config."""

    def __init__(self, languages=None, **kwargs):
        super(STS22Task8Config, self).__init__(version=datasets.Version(_VERSION, ""), **kwargs),
        self.languages = languages


class STS22Task8(datasets.GeneratorBasedBuilder):

    """Multilingual News Article Similarity"""

    BUILDER_CONFIGS = [
        STS22Task8Config(
            name=_ALL_LANGUAGES,
            languages=_LANGUAGES,
            description="Multilingual News Article Similarity",
        )
    ] + [
        STS22Task8Config(
            name=lang,
            languages=[lang],
            description=f"{_LANGUAGES[lang]} examples from a collection of multilingual news articles",
        )
        for lang in _LANGUAGES
    ]
    BUILDER_CONFIG_CLASS = STS22Task8Config
    DEFAULT_CONFIG_NAME = _ALL_LANGUAGES

    def _info(self):
        return datasets.DatasetInfo(
            description=_DESCRIPTION,
            features=datasets.Features(
                {
                    "id": datasets.Value("string"),
                    "sentence1": datasets.Value("string"),
                    "sentence2": datasets.Value("string"),
                    "score": datasets.Value("float32"),
                },
            ),
            supervised_keys=None,
            license=_LICENSE,
            homepage=_HOMEPAGE_URL,
            citation=_CITATION,
        )

    def _split_generators(self, dl_manager):
        # train_urls = [_DOWNLOAD_URL.format(split="train", lang=lang) for lang in self.config.languages if lang in _LANGUAGES_TRAIN]
        test_urls = [
            _DOWNLOAD_URL.format(split="test", lang=lang) for lang in self.config.languages if lang in _LANGUAGES_TEST
        ]

        # train_paths = dl_manager.download_and_extract(train_urls)
        test_paths = dl_manager.download_and_extract(test_urls)

        return [
            # datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"file_paths": train_paths}),
            datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"file_paths": test_paths}),
        ]

    def _generate_examples(self, file_paths):
        row_count = 0
        for file_path in file_paths:
            with open(file_path, "r", encoding="utf-8") as f:
                for line in f:
                    yield row_count, json.loads(line)
                    row_count += 1