Datasets:
lm
commited on
Commit
·
de9d86b
1
Parent(s):
eab3705
rm script
Browse files- sts22-crosslingual-sts.py +0 -119
sts22-crosslingual-sts.py
DELETED
@@ -1,119 +0,0 @@
|
|
1 |
-
import json
|
2 |
-
import datasets
|
3 |
-
import os
|
4 |
-
|
5 |
-
_CITATION = """\
|
6 |
-
"""
|
7 |
-
|
8 |
-
_LICENSE = """\
|
9 |
-
"""
|
10 |
-
|
11 |
-
_DESCRIPTION = """\
|
12 |
-
SemEval 2022 Task 8: Multilingual News Article Similarity
|
13 |
-
"""
|
14 |
-
|
15 |
-
_LANGUAGES_TRAIN = {
|
16 |
-
"en": "en",
|
17 |
-
"de": "de",
|
18 |
-
"es": "es",
|
19 |
-
"pl": "pl",
|
20 |
-
"tr": "tr",
|
21 |
-
"fr": "fr",
|
22 |
-
"ar": "ar",
|
23 |
-
"de-en": "de-en",
|
24 |
-
}
|
25 |
-
_LANGUAGES_TEST = {
|
26 |
-
"en": "en",
|
27 |
-
"de": "de",
|
28 |
-
"es": "es",
|
29 |
-
"pl": "pl",
|
30 |
-
"tr": "tr",
|
31 |
-
"ar": "ar",
|
32 |
-
"ru": "ru",
|
33 |
-
"zh": "zh",
|
34 |
-
"fr": "fr",
|
35 |
-
"de-en": "de-en",
|
36 |
-
"es-en": "es-en",
|
37 |
-
"it": "it",
|
38 |
-
"pl-en": "pl-en",
|
39 |
-
"zh-en": "zh-en",
|
40 |
-
"es-it": "es-it",
|
41 |
-
"de-fr": "de-fr",
|
42 |
-
"de-pl": "de-pl",
|
43 |
-
"fr-pl": "fr-pl",
|
44 |
-
}
|
45 |
-
_LANGUAGES = {**_LANGUAGES_TRAIN, **_LANGUAGES_TEST}
|
46 |
-
|
47 |
-
_ALL_LANGUAGES = "all_languages"
|
48 |
-
_HOMEPAGE_URL = "https://competitions.codalab.org/competitions/33835"
|
49 |
-
_DOWNLOAD_URL = "{lang}/{split}.jsonl"
|
50 |
-
_VERSION = "1.0.1"
|
51 |
-
|
52 |
-
|
53 |
-
class STS22Task8Config(datasets.BuilderConfig):
|
54 |
-
"""BuilderConfig for STS22Task8Config."""
|
55 |
-
|
56 |
-
def __init__(self, languages=None, **kwargs):
|
57 |
-
super(STS22Task8Config, self).__init__(version=datasets.Version(_VERSION, ""), **kwargs),
|
58 |
-
self.languages = languages
|
59 |
-
|
60 |
-
|
61 |
-
class STS22Task8(datasets.GeneratorBasedBuilder):
|
62 |
-
|
63 |
-
"""Multilingual News Article Similarity"""
|
64 |
-
|
65 |
-
BUILDER_CONFIGS = [
|
66 |
-
STS22Task8Config(
|
67 |
-
name=_ALL_LANGUAGES,
|
68 |
-
languages=_LANGUAGES,
|
69 |
-
description="Multilingual News Article Similarity",
|
70 |
-
)
|
71 |
-
] + [
|
72 |
-
STS22Task8Config(
|
73 |
-
name=lang,
|
74 |
-
languages=[lang],
|
75 |
-
description=f"{_LANGUAGES[lang]} examples from a collection of multilingual news articles",
|
76 |
-
)
|
77 |
-
for lang in _LANGUAGES
|
78 |
-
]
|
79 |
-
BUILDER_CONFIG_CLASS = STS22Task8Config
|
80 |
-
DEFAULT_CONFIG_NAME = _ALL_LANGUAGES
|
81 |
-
|
82 |
-
def _info(self):
|
83 |
-
return datasets.DatasetInfo(
|
84 |
-
description=_DESCRIPTION,
|
85 |
-
features=datasets.Features(
|
86 |
-
{
|
87 |
-
"id": datasets.Value("string"),
|
88 |
-
"sentence1": datasets.Value("string"),
|
89 |
-
"sentence2": datasets.Value("string"),
|
90 |
-
"score": datasets.Value("float32"),
|
91 |
-
},
|
92 |
-
),
|
93 |
-
supervised_keys=None,
|
94 |
-
license=_LICENSE,
|
95 |
-
homepage=_HOMEPAGE_URL,
|
96 |
-
citation=_CITATION,
|
97 |
-
)
|
98 |
-
|
99 |
-
def _split_generators(self, dl_manager):
|
100 |
-
# train_urls = [_DOWNLOAD_URL.format(split="train", lang=lang) for lang in self.config.languages if lang in _LANGUAGES_TRAIN]
|
101 |
-
test_urls = [
|
102 |
-
_DOWNLOAD_URL.format(split="test", lang=lang) for lang in self.config.languages if lang in _LANGUAGES_TEST
|
103 |
-
]
|
104 |
-
|
105 |
-
# train_paths = dl_manager.download_and_extract(train_urls)
|
106 |
-
test_paths = dl_manager.download_and_extract(test_urls)
|
107 |
-
|
108 |
-
return [
|
109 |
-
# datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"file_paths": train_paths}),
|
110 |
-
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"file_paths": test_paths}),
|
111 |
-
]
|
112 |
-
|
113 |
-
def _generate_examples(self, file_paths):
|
114 |
-
row_count = 0
|
115 |
-
for file_path in file_paths:
|
116 |
-
with open(file_path, "r", encoding="utf-8") as f:
|
117 |
-
for line in f:
|
118 |
-
yield row_count, json.loads(line)
|
119 |
-
row_count += 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|