ortpractico commited on
Commit
0f87bf5
·
verified ·
1 Parent(s): 315eff5

Delete loading script

Browse files
Files changed (1) hide show
  1. kde4.py +0 -129
kde4.py DELETED
@@ -1,129 +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
- 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