Datasets:

Multilinguality:
multilingual
Size Categories:
100K<n<1M
Language Creators:
found
Annotations Creators:
found
Source Datasets:
original
Tags:
License:
system HF staff commited on
Commit
8f9306a
0 Parent(s):

Update files from the datasets library (from 1.2.0)

Browse files

Release notes: https://github.com/huggingface/datasets/releases/tag/1.2.0

.gitattributes ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bin.* filter=lfs diff=lfs merge=lfs -text
5
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.model filter=lfs diff=lfs merge=lfs -text
12
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
13
+ *.onnx filter=lfs diff=lfs merge=lfs -text
14
+ *.ot filter=lfs diff=lfs merge=lfs -text
15
+ *.parquet filter=lfs diff=lfs merge=lfs -text
16
+ *.pb filter=lfs diff=lfs merge=lfs -text
17
+ *.pt filter=lfs diff=lfs merge=lfs -text
18
+ *.pth filter=lfs diff=lfs merge=lfs -text
19
+ *.rar filter=lfs diff=lfs merge=lfs -text
20
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
21
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
22
+ *.tflite filter=lfs diff=lfs merge=lfs -text
23
+ *.tgz filter=lfs diff=lfs merge=lfs -text
24
+ *.xz filter=lfs diff=lfs merge=lfs -text
25
+ *.zip filter=lfs diff=lfs merge=lfs -text
26
+ *.zstandard filter=lfs diff=lfs merge=lfs -text
27
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,235 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ annotations_creators:
3
+ - found
4
+ language_creators:
5
+ - found
6
+ languages:
7
+ - af
8
+ - ar
9
+ - as
10
+ - ast
11
+ - be
12
+ - bg
13
+ - bn
14
+ - bn_IN
15
+ - br
16
+ - ca
17
+ - crh
18
+ - cs
19
+ - csb
20
+ - cy
21
+ - da
22
+ - de
23
+ - el
24
+ - en
25
+ - en_GB
26
+ - eo
27
+ - es
28
+ - et
29
+ - eu
30
+ - fa
31
+ - fi
32
+ - fr
33
+ - fy
34
+ - ga
35
+ - gl
36
+ - gu
37
+ - ha
38
+ - he
39
+ - hi
40
+ - hne
41
+ - hr
42
+ - hsb
43
+ - hu
44
+ - hy
45
+ - id
46
+ - is
47
+ - it
48
+ - ja
49
+ - ka
50
+ - kk
51
+ - km
52
+ - kn
53
+ - ko
54
+ - ku
55
+ - lb
56
+ - lt
57
+ - lv
58
+ - mai
59
+ - mk
60
+ - ml
61
+ - mr
62
+ - ms
63
+ - mt
64
+ - nb
65
+ - nds
66
+ - ne
67
+ - nl
68
+ - nn
69
+ - nso
70
+ - oc
71
+ - or
72
+ - pa
73
+ - pl
74
+ - ps
75
+ - pt
76
+ - pt_BR
77
+ - ro
78
+ - ru
79
+ - rw
80
+ - se
81
+ - si
82
+ - sk
83
+ - sl
84
+ - sr
85
+ - sv
86
+ - ta
87
+ - te
88
+ - tg
89
+ - th
90
+ - tr
91
+ - uk
92
+ - uz
93
+ - vi
94
+ - wa
95
+ - xh
96
+ - zh_CN
97
+ - zh_HK
98
+ - zh_TW
99
+ licenses:
100
+ - unknown
101
+ multilinguality:
102
+ - multilingual
103
+ size_categories:
104
+ - 100K<n<1M
105
+ source_datasets:
106
+ - original
107
+ task_categories:
108
+ - conditional-text-generation
109
+ task_ids:
110
+ - machine-translation
111
+ ---
112
+ # Dataset Card Creation Guide
113
+
114
+ ## Table of Contents
115
+ - [Dataset Description](#dataset-description)
116
+ - [Dataset Summary](#dataset-summary)
117
+ - [Supported Tasks](#supported-tasks-and-leaderboards)
118
+ - [Languages](#languages)
119
+ - [Dataset Structure](#dataset-structure)
120
+ - [Data Instances](#data-instances)
121
+ - [Data Fields](#data-instances)
122
+ - [Data Splits](#data-instances)
123
+ - [Dataset Creation](#dataset-creation)
124
+ - [Curation Rationale](#curation-rationale)
125
+ - [Source Data](#source-data)
126
+ - [Annotations](#annotations)
127
+ - [Personal and Sensitive Information](#personal-and-sensitive-information)
128
+ - [Considerations for Using the Data](#considerations-for-using-the-data)
129
+ - [Social Impact of Dataset](#social-impact-of-dataset)
130
+ - [Discussion of Biases](#discussion-of-biases)
131
+ - [Other Known Limitations](#other-known-limitations)
132
+ - [Additional Information](#additional-information)
133
+ - [Dataset Curators](#dataset-curators)
134
+ - [Licensing Information](#licensing-information)
135
+ - [Citation Information](#citation-information)
136
+
137
+ ## Dataset Description
138
+
139
+ - **Homepage:** http://opus.nlpl.eu/KDE4.php
140
+ - **Repository:** None
141
+ - **Paper:** http://www.lrec-conf.org/proceedings/lrec2012/pdf/463_Paper.pdf
142
+ - **Leaderboard:** [More Information Needed]
143
+ - **Point of Contact:** [More Information Needed]
144
+
145
+ ### Dataset Summary
146
+
147
+ To load a language pair which isn't part of the config, all you need to do is specify the language code as pairs.
148
+ You can find the valid pairs in Homepage section of Dataset Description: http://opus.nlpl.eu/KDE4.php
149
+ E.g.
150
+
151
+ `dataset = load_dataset("kde4", lang1="en", lang2="nl")`
152
+
153
+ ### Supported Tasks and Leaderboards
154
+
155
+ [More Information Needed]
156
+
157
+ ### Languages
158
+
159
+ [More Information Needed]
160
+
161
+ ## Dataset Structure
162
+
163
+ ### Data Instances
164
+
165
+ [More Information Needed]
166
+
167
+ ### Data Fields
168
+
169
+ [More Information Needed]
170
+
171
+ ### Data Splits
172
+
173
+ [More Information Needed]
174
+
175
+ ## Dataset Creation
176
+
177
+ ### Curation Rationale
178
+
179
+ [More Information Needed]
180
+
181
+ ### Source Data
182
+
183
+ [More Information Needed]
184
+
185
+ #### Initial Data Collection and Normalization
186
+
187
+ [More Information Needed]
188
+
189
+ #### Who are the source language producers?
190
+
191
+ [More Information Needed]
192
+
193
+ ### Annotations
194
+
195
+ [More Information Needed]
196
+
197
+ #### Annotation process
198
+
199
+ [More Information Needed]
200
+
201
+ #### Who are the annotators?
202
+
203
+ [More Information Needed]
204
+
205
+ ### Personal and Sensitive Information
206
+
207
+ [More Information Needed]
208
+
209
+ ## Considerations for Using the Data
210
+
211
+ ### Social Impact of Dataset
212
+
213
+ [More Information Needed]
214
+
215
+ ### Discussion of Biases
216
+
217
+ [More Information Needed]
218
+
219
+ ### Other Known Limitations
220
+
221
+ [More Information Needed]
222
+
223
+ ## Additional Information
224
+
225
+ ### Dataset Curators
226
+
227
+ [More Information Needed]
228
+
229
+ ### Licensing Information
230
+
231
+ [More Information Needed]
232
+
233
+ ### Citation Information
234
+
235
+ [More Information Needed]
dataset_infos.json ADDED
@@ -0,0 +1 @@
 
1
+ {"fi-nl": {"description": "A parallel corpus of KDE4 localization files (v.2).\n\n92 languages, 4,099 bitexts\ntotal number of files: 75,535\ntotal number of tokens: 60.75M\ntotal number of sentence fragments: 8.89M\n", "citation": "@InProceedings{TIEDEMANN12.463,\n author = {J\ufffdrg Tiedemann},\n title = {Parallel Data, Tools and Interfaces in OPUS},\n booktitle = {Proceedings of the Eight International Conference on Language Resources and Evaluation (LREC'12)},\n year = {2012},\n month = {may},\n date = {23-25},\n address = {Istanbul, Turkey},\n editor = {Nicoletta Calzolari (Conference Chair) and Khalid Choukri and Thierry Declerck and Mehmet Ugur Dogan and Bente Maegaard and Joseph Mariani and Jan Odijk and Stelios Piperidis},\n publisher = {European Language Resources Association (ELRA)},\n isbn = {978-2-9517408-7-7},\n language = {english}\n }\n", "homepage": "http://opus.nlpl.eu/KDE4.php", "license": "", "features": {"id": {"dtype": "string", "id": null, "_type": "Value"}, "translation": {"languages": ["fi", "nl"], "id": null, "_type": "Translation"}}, "post_processed": null, "supervised_keys": null, "builder_name": "kde4", "config_name": "fi-nl", "version": {"version_str": "2.0.0", "description": "", "major": 2, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 8845933, "num_examples": 101593, "dataset_name": "kde4"}}, "download_checksums": {"https://object.pouta.csc.fi/OPUS-KDE4/v2/moses/fi-nl.txt.zip": {"num_bytes": 2471355, "checksum": "67b79c0b978826f41b53d3e8c560c5dd70f1135b1c3bad1bce4ae46bc3b6a111"}}, "download_size": 2471355, "post_processing_size": null, "dataset_size": 8845933, "size_in_bytes": 11317288}, "it-ro": {"description": "A parallel corpus of KDE4 localization files (v.2).\n\n92 languages, 4,099 bitexts\ntotal number of files: 75,535\ntotal number of tokens: 60.75M\ntotal number of sentence fragments: 8.89M\n", "citation": "@InProceedings{TIEDEMANN12.463,\n author = {J\ufffdrg Tiedemann},\n title = {Parallel Data, Tools and Interfaces in OPUS},\n booktitle = {Proceedings of the Eight International Conference on Language Resources and Evaluation (LREC'12)},\n year = {2012},\n month = {may},\n date = {23-25},\n address = {Istanbul, Turkey},\n editor = {Nicoletta Calzolari (Conference Chair) and Khalid Choukri and Thierry Declerck and Mehmet Ugur Dogan and Bente Maegaard and Joseph Mariani and Jan Odijk and Stelios Piperidis},\n publisher = {European Language Resources Association (ELRA)},\n isbn = {978-2-9517408-7-7},\n language = {english}\n }\n", "homepage": "http://opus.nlpl.eu/KDE4.php", "license": "", "features": {"id": {"dtype": "string", "id": null, "_type": "Value"}, "translation": {"languages": ["it", "ro"], "id": null, "_type": "Translation"}}, "post_processed": null, "supervised_keys": null, "builder_name": "kde4", "config_name": "it-ro", "version": {"version_str": "2.0.0", "description": "", "major": 2, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 8827049, "num_examples": 109003, "dataset_name": "kde4"}}, "download_checksums": {"https://object.pouta.csc.fi/OPUS-KDE4/v2/moses/it-ro.txt.zip": {"num_bytes": 2389051, "checksum": "6810b79d144de10f262a69e63f54b6c1e18430553984c0bbcc180561f6e7444d"}}, "download_size": 2389051, "post_processing_size": null, "dataset_size": 8827049, "size_in_bytes": 11216100}, "nl-sv": {"description": "A parallel corpus of KDE4 localization files (v.2).\n\n92 languages, 4,099 bitexts\ntotal number of files: 75,535\ntotal number of tokens: 60.75M\ntotal number of sentence fragments: 8.89M\n", "citation": "@InProceedings{TIEDEMANN12.463,\n author = {J\ufffdrg Tiedemann},\n title = {Parallel Data, Tools and Interfaces in OPUS},\n booktitle = {Proceedings of the Eight International Conference on Language Resources and Evaluation (LREC'12)},\n year = {2012},\n month = {may},\n date = {23-25},\n address = {Istanbul, Turkey},\n editor = {Nicoletta Calzolari (Conference Chair) and Khalid Choukri and Thierry Declerck and Mehmet Ugur Dogan and Bente Maegaard and Joseph Mariani and Jan Odijk and Stelios Piperidis},\n publisher = {European Language Resources Association (ELRA)},\n isbn = {978-2-9517408-7-7},\n language = {english}\n }\n", "homepage": "http://opus.nlpl.eu/KDE4.php", "license": "", "features": {"id": {"dtype": "string", "id": null, "_type": "Value"}, "translation": {"languages": ["nl", "sv"], "id": null, "_type": "Translation"}}, "post_processed": null, "supervised_keys": null, "builder_name": "kde4", "config_name": "nl-sv", "version": {"version_str": "2.0.0", "description": "", "major": 2, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 22294586, "num_examples": 188454, "dataset_name": "kde4"}}, "download_checksums": {"https://object.pouta.csc.fi/OPUS-KDE4/v2/moses/nl-sv.txt.zip": {"num_bytes": 6203460, "checksum": "7b38481cf9e838a587123c6328e2a3dea93d4a2c1060c5b300fb485ba830cc21"}}, "download_size": 6203460, "post_processing_size": null, "dataset_size": 22294586, "size_in_bytes": 28498046}, "en-it": {"description": "A parallel corpus of KDE4 localization files (v.2).\n\n92 languages, 4,099 bitexts\ntotal number of files: 75,535\ntotal number of tokens: 60.75M\ntotal number of sentence fragments: 8.89M\n", "citation": "@InProceedings{TIEDEMANN12.463,\n author = {J\ufffdrg Tiedemann},\n title = {Parallel Data, Tools and Interfaces in OPUS},\n booktitle = {Proceedings of the Eight International Conference on Language Resources and Evaluation (LREC'12)},\n year = {2012},\n month = {may},\n date = {23-25},\n address = {Istanbul, Turkey},\n editor = {Nicoletta Calzolari (Conference Chair) and Khalid Choukri and Thierry Declerck and Mehmet Ugur Dogan and Bente Maegaard and Joseph Mariani and Jan Odijk and Stelios Piperidis},\n publisher = {European Language Resources Association (ELRA)},\n isbn = {978-2-9517408-7-7},\n language = {english}\n }\n", "homepage": "http://opus.nlpl.eu/KDE4.php", "license": "", "features": {"id": {"dtype": "string", "id": null, "_type": "Value"}, "translation": {"languages": ["en", "it"], "id": null, "_type": "Translation"}}, "post_processed": null, "supervised_keys": null, "builder_name": "kde4", "config_name": "en-it", "version": {"version_str": "2.0.0", "description": "", "major": 2, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 27132585, "num_examples": 220566, "dataset_name": "kde4"}}, "download_checksums": {"https://object.pouta.csc.fi/OPUS-KDE4/v2/moses/en-it.txt.zip": {"num_bytes": 7622662, "checksum": "a25227326866a070251a75119f2e5d0554a9bf0d8c8aa5d41487f4288b834600"}}, "download_size": 7622662, "post_processing_size": null, "dataset_size": 27132585, "size_in_bytes": 34755247}, "en-fr": {"description": "A parallel corpus of KDE4 localization files (v.2).\n\n92 languages, 4,099 bitexts\ntotal number of files: 75,535\ntotal number of tokens: 60.75M\ntotal number of sentence fragments: 8.89M\n", "citation": "@InProceedings{TIEDEMANN12.463,\n author = {J\ufffdrg Tiedemann},\n title = {Parallel Data, Tools and Interfaces in OPUS},\n booktitle = {Proceedings of the Eight International Conference on Language Resources and Evaluation (LREC'12)},\n year = {2012},\n month = {may},\n date = {23-25},\n address = {Istanbul, Turkey},\n editor = {Nicoletta Calzolari (Conference Chair) and Khalid Choukri and Thierry Declerck and Mehmet Ugur Dogan and Bente Maegaard and Joseph Mariani and Jan Odijk and Stelios Piperidis},\n publisher = {European Language Resources Association (ELRA)},\n isbn = {978-2-9517408-7-7},\n language = {english}\n }\n", "homepage": "http://opus.nlpl.eu/KDE4.php", "license": "", "features": {"id": {"dtype": "string", "id": null, "_type": "Value"}, "translation": {"languages": ["en", "fr"], "id": null, "_type": "Translation"}}, "post_processed": null, "supervised_keys": null, "builder_name": "kde4", "config_name": "en-fr", "version": {"version_str": "2.0.0", "description": "", "major": 2, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 25650409, "num_examples": 210173, "dataset_name": "kde4"}}, "download_checksums": {"https://object.pouta.csc.fi/OPUS-KDE4/v2/moses/en-fr.txt.zip": {"num_bytes": 7049364, "checksum": "7ffc0c96d8b27740f58ebaf84a0d3434bb130e714e1a1b9522cb6d3fbb313034"}}, "download_size": 7049364, "post_processing_size": null, "dataset_size": 25650409, "size_in_bytes": 32699773}}
dummy/en-fr/2.0.0/dummy_data.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:62cd8ad6efd7a8c67d90d0ee914f812efd841c50dd85dc94bf3bff42bba2aba9
3
+ size 1186
dummy/en-it/2.0.0/dummy_data.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:996ed0765d828bd7441c1a0d0d1a83836d62fe1371ca7432141f232291ab28eb
3
+ size 1244
dummy/fi-nl/2.0.0/dummy_data.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f8c8cddcf6cac4fa9992e24d16f4cd572575c40c766695d6a0e1fa5f6945a6b8
3
+ size 1127
dummy/it-ro/2.0.0/dummy_data.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:658c5a776f8aced33af05bc3c4d023c427f02ff2d7b5fcfe968987bbd9feb513
3
+ size 1846
dummy/nl-sv/2.0.0/dummy_data.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5070bd1b0798f3a50c24d06cd865e5c9dc900884b1a687f7307e5019cb75a714
3
+ size 1234
kde4.py ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ import os
18
+
19
+ import datasets
20
+
21
+
22
+ _DESCRIPTION = """\
23
+ A parallel corpus of KDE4 localization files (v.2).
24
+
25
+ 92 languages, 4,099 bitexts
26
+ total number of files: 75,535
27
+ total number of tokens: 60.75M
28
+ total number of sentence fragments: 8.89M
29
+ """
30
+ _HOMEPAGE_URL = "http://opus.nlpl.eu/KDE4.php"
31
+ _CITATION = """\
32
+ @InProceedings{TIEDEMANN12.463,
33
+ author = {J{\"o}rg Tiedemann},
34
+ title = {Parallel Data, Tools and Interfaces in OPUS},
35
+ booktitle = {Proceedings of the Eight International Conference on Language Resources and Evaluation (LREC'12)},
36
+ year = {2012},
37
+ month = {may},
38
+ date = {23-25},
39
+ address = {Istanbul, Turkey},
40
+ editor = {Nicoletta Calzolari (Conference Chair) and Khalid Choukri and Thierry Declerck and Mehmet Ugur Dogan and Bente Maegaard and Joseph Mariani and Jan Odijk and Stelios Piperidis},
41
+ publisher = {European Language Resources Association (ELRA)},
42
+ isbn = {978-2-9517408-7-7},
43
+ language = {english}
44
+ }
45
+ """
46
+
47
+ _VERSION = "2.0.0"
48
+ _BASE_NAME = "KDE4.{}.{}"
49
+ _BASE_URL = "https://object.pouta.csc.fi/OPUS-KDE4/v2/moses/{}-{}.txt.zip"
50
+
51
+ # Please note that only few pairs are shown here. You can use config to generate data for all language pairs
52
+ _LANGUAGE_PAIRS = [
53
+ ("fi", "nl"),
54
+ ("it", "ro"),
55
+ ("nl", "sv"),
56
+ ("en", "it"),
57
+ ("en", "fr"),
58
+ ]
59
+
60
+
61
+ class Kde4Config(datasets.BuilderConfig):
62
+ def __init__(self, *args, lang1=None, lang2=None, **kwargs):
63
+ super().__init__(
64
+ *args,
65
+ name=f"{lang1}-{lang2}",
66
+ **kwargs,
67
+ )
68
+ self.lang1 = lang1
69
+ self.lang2 = lang2
70
+
71
+
72
+ class Kde4(datasets.GeneratorBasedBuilder):
73
+ BUILDER_CONFIGS = [
74
+ Kde4Config(
75
+ lang1=lang1,
76
+ lang2=lang2,
77
+ description=f"Translating {lang1} to {lang2} or vice versa",
78
+ version=datasets.Version(_VERSION),
79
+ )
80
+ for lang1, lang2 in _LANGUAGE_PAIRS
81
+ ]
82
+ BUILDER_CONFIG_CLASS = Kde4Config
83
+
84
+ def _info(self):
85
+ return datasets.DatasetInfo(
86
+ description=_DESCRIPTION,
87
+ features=datasets.Features(
88
+ {
89
+ "id": datasets.Value("string"),
90
+ "translation": datasets.Translation(languages=(self.config.lang1, self.config.lang2)),
91
+ },
92
+ ),
93
+ supervised_keys=None,
94
+ homepage=_HOMEPAGE_URL,
95
+ citation=_CITATION,
96
+ )
97
+
98
+ def _split_generators(self, dl_manager):
99
+ def _base_url(lang1, lang2):
100
+ return _BASE_URL.format(lang1, lang2)
101
+
102
+ download_url = _base_url(self.config.lang1, self.config.lang2)
103
+ path = dl_manager.download_and_extract(download_url)
104
+ return [
105
+ datasets.SplitGenerator(
106
+ name=datasets.Split.TRAIN,
107
+ gen_kwargs={"datapath": path},
108
+ )
109
+ ]
110
+
111
+ def _generate_examples(self, datapath):
112
+ l1, l2 = self.config.lang1, self.config.lang2
113
+ folder = l1 + "-" + l2
114
+ l1_file = _BASE_NAME.format(folder, l1)
115
+ l2_file = _BASE_NAME.format(folder, l2)
116
+ l1_path = os.path.join(datapath, l1_file)
117
+ l2_path = os.path.join(datapath, l2_file)
118
+ with open(l1_path, encoding="utf-8") as f1, open(l2_path, encoding="utf-8") as f2:
119
+ for sentence_counter, (x, y) in enumerate(zip(f1, f2)):
120
+ x = x.strip()
121
+ y = y.strip()
122
+ result = (
123
+ sentence_counter,
124
+ {
125
+ "id": str(sentence_counter),
126
+ "translation": {l1: x, l2: y},
127
+ },
128
+ )
129
+ yield result