albertvillanova HF staff commited on
Commit
858ae08
1 Parent(s): 949c2e3

Delete loading script

Browse files
Files changed (1) hide show
  1. setimes.py +0 -158
setimes.py DELETED
@@ -1,158 +0,0 @@
1
- # coding=utf-8
2
- # Copyright 2020 HuggingFace Datasets Authors.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
-
16
- # Lint as: python3
17
-
18
- import datasets
19
-
20
-
21
- _DESCRIPTION = """\
22
- SETimes – A Parallel Corpus of English and South-East European Languages
23
- The corpus is based on the content published on the SETimes.com news portal. The news portal publishes “news and views from Southeast Europe” in ten languages: Bulgarian, Bosnian, Greek, English, Croatian, Macedonian, Romanian, Albanian and Serbian. This version of the corpus tries to solve the issues present in an older version of the corpus (published inside OPUS, described in the LREC 2010 paper by Francis M. Tyers and Murat Serdar Alperen). The following procedures were applied to resolve existing issues:
24
-
25
- - stricter extraction process – no HTML residues present
26
- - language identification on every non-English document – non-English online documents contain English material in case the article was not translated into that language
27
- - resolving encoding issues in Croatian and Serbian – diacritics were partially lost due to encoding errors – text was rediacritized.
28
- """
29
- _HOMEPAGE_URL = "http://nlp.ffzg.hr/resources/corpora/setimes/"
30
- _CITATION = None
31
-
32
- _VERSION = "1.0.0"
33
- _BASE_NAME = "setimes.{}-{}.{}.txt"
34
- _BASE_URL = "http://nlp.ffzg.hr/data/corpora/setimes/setimes.{}-{}.txt.tgz"
35
-
36
- _LANGUAGE_PAIRS = [
37
- ("bg", "bs"),
38
- ("bg", "el"),
39
- ("bs", "el"),
40
- ("bg", "en"),
41
- ("bs", "en"),
42
- ("el", "en"),
43
- ("bg", "hr"),
44
- ("bs", "hr"),
45
- ("el", "hr"),
46
- ("en", "hr"),
47
- ("bg", "mk"),
48
- ("bs", "mk"),
49
- ("el", "mk"),
50
- ("en", "mk"),
51
- ("hr", "mk"),
52
- ("bg", "ro"),
53
- ("bs", "ro"),
54
- ("el", "ro"),
55
- ("en", "ro"),
56
- ("hr", "ro"),
57
- ("mk", "ro"),
58
- ("bg", "sq"),
59
- ("bs", "sq"),
60
- ("el", "sq"),
61
- ("en", "sq"),
62
- ("hr", "sq"),
63
- ("mk", "sq"),
64
- ("ro", "sq"),
65
- ("bg", "sr"),
66
- ("bs", "sr"),
67
- ("el", "sr"),
68
- ("en", "sr"),
69
- ("hr", "sr"),
70
- ("mk", "sr"),
71
- ("ro", "sr"),
72
- ("sq", "sr"),
73
- ("bg", "tr"),
74
- ("bs", "tr"),
75
- ("el", "tr"),
76
- ("en", "tr"),
77
- ("hr", "tr"),
78
- ("mk", "tr"),
79
- ("ro", "tr"),
80
- ("sq", "tr"),
81
- ("sr", "tr"),
82
- ]
83
-
84
-
85
- class SetimesConfig(datasets.BuilderConfig):
86
- def __init__(self, *args, lang1=None, lang2=None, **kwargs):
87
- super().__init__(
88
- *args,
89
- name=f"{lang1}-{lang2}",
90
- **kwargs,
91
- )
92
- self.lang1 = lang1
93
- self.lang2 = lang2
94
-
95
-
96
- class Setimes(datasets.GeneratorBasedBuilder):
97
- BUILDER_CONFIGS = [
98
- SetimesConfig(
99
- lang1=lang1,
100
- lang2=lang2,
101
- description=f"Translating {lang1} to {lang2} or vice versa",
102
- version=datasets.Version(_VERSION),
103
- )
104
- for lang1, lang2 in _LANGUAGE_PAIRS
105
- ]
106
- BUILDER_CONFIG_CLASS = SetimesConfig
107
-
108
- def _info(self):
109
- return datasets.DatasetInfo(
110
- description=_DESCRIPTION,
111
- features=datasets.Features(
112
- {
113
- "id": datasets.Value("string"),
114
- "translation": datasets.Translation(languages=(self.config.lang1, self.config.lang2)),
115
- },
116
- ),
117
- supervised_keys=None,
118
- homepage=_HOMEPAGE_URL,
119
- citation=_CITATION,
120
- )
121
-
122
- def _split_generators(self, dl_manager):
123
- def _base_url(lang1, lang2):
124
- return _BASE_URL.format(lang1, lang2)
125
-
126
- download_url = _base_url(self.config.lang1, self.config.lang2)
127
- archive = dl_manager.download(download_url)
128
- return [
129
- datasets.SplitGenerator(
130
- name=datasets.Split.TRAIN,
131
- gen_kwargs={
132
- "l1_files": dl_manager.iter_archive(archive),
133
- "l2_files": dl_manager.iter_archive(archive),
134
- },
135
- )
136
- ]
137
-
138
- def _generate_examples(self, l1_files, l2_files):
139
- l1, l2 = self.config.lang1, self.config.lang2
140
- l1_file = _BASE_NAME.format(l1, l2, l1)
141
- l2_file = _BASE_NAME.format(l1, l2, l2)
142
- for path1, f1 in l1_files:
143
- if path1 == l1_file:
144
- for path2, f2 in l2_files:
145
- if path2 == l2_file:
146
- for sentence_counter, (x, y) in enumerate(zip(f1, f2)):
147
- x = x.decode("utf-8").strip()
148
- y = y.decode("utf-8").strip()
149
- result = (
150
- sentence_counter,
151
- {
152
- "id": str(sentence_counter),
153
- "translation": {l1: x, l2: y},
154
- },
155
- )
156
- yield result
157
- break
158
- break