albertvillanova HF staff commited on
Commit
e4e28e4
1 Parent(s): 38045a5

Delete loading script

Browse files
Files changed (1) hide show
  1. opus_ubuntu.py +0 -132
opus_ubuntu.py DELETED
@@ -1,132 +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 Ubuntu localization files. Source: https://translations.launchpad.net
24
- 244 languages, 23,988 bitexts
25
- total number of files: 30,959
26
- total number of tokens: 29.84M
27
- total number of sentence fragments: 7.73M
28
- """
29
- _HOMEPAGE_URL = "http://opus.nlpl.eu/Ubuntu.php"
30
- _CITATION = """\
31
- @InProceedings{TIEDEMANN12.463,
32
- author = {J{\"o}rg Tiedemann},
33
- title = {Parallel Data, Tools and Interfaces in OPUS},
34
- booktitle = {Proceedings of the Eight International Conference on Language Resources and Evaluation (LREC'12)},
35
- year = {2012},
36
- month = {may},
37
- date = {23-25},
38
- address = {Istanbul, Turkey},
39
- 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},
40
- publisher = {European Language Resources Association (ELRA)},
41
- isbn = {978-2-9517408-7-7},
42
- language = {english}
43
- }
44
- """
45
-
46
- _VERSION = "1.0.0"
47
- _BASE_NAME = "Ubuntu.{}.{}"
48
- _BASE_URL = "https://object.pouta.csc.fi/OPUS-Ubuntu/v14.10/moses/{}-{}.txt.zip"
49
- # Please note that only few pairs are shown here. You can use config to generate data for all language pairs
50
- _LANGUAGE_PAIRS = [
51
- ("as", "bs"),
52
- ("az", "cs"),
53
- ("bg", "de"),
54
- ("br", "es_PR"),
55
- ("bn", "ga"),
56
- ("br", "hi"),
57
- ("br", "la"),
58
- ("bs", "szl"),
59
- ("br", "uz"),
60
- ("br", "yi"),
61
- ]
62
-
63
-
64
- class UbuntuConfig(datasets.BuilderConfig):
65
- def __init__(self, *args, lang1=None, lang2=None, **kwargs):
66
- super().__init__(
67
- *args,
68
- name=f"{lang1}-{lang2}",
69
- **kwargs,
70
- )
71
- self.lang1 = lang1
72
- self.lang2 = lang2
73
-
74
-
75
- class OpusUbuntu(datasets.GeneratorBasedBuilder):
76
- BUILDER_CONFIGS = [
77
- UbuntuConfig(
78
- lang1=lang1,
79
- lang2=lang2,
80
- description=f"Translating {lang1} to {lang2} or vice versa",
81
- version=datasets.Version(_VERSION),
82
- )
83
- for lang1, lang2 in _LANGUAGE_PAIRS
84
- ]
85
- BUILDER_CONFIG_CLASS = UbuntuConfig
86
-
87
- def _info(self):
88
- return datasets.DatasetInfo(
89
- description=_DESCRIPTION,
90
- features=datasets.Features(
91
- {
92
- "id": datasets.Value("string"),
93
- "translation": datasets.Translation(languages=(self.config.lang1, self.config.lang2)),
94
- },
95
- ),
96
- supervised_keys=None,
97
- homepage=_HOMEPAGE_URL,
98
- citation=_CITATION,
99
- )
100
-
101
- def _split_generators(self, dl_manager):
102
- def _base_url(lang1, lang2):
103
- return _BASE_URL.format(lang1, lang2)
104
-
105
- download_url = _base_url(self.config.lang1, self.config.lang2)
106
- path = dl_manager.download_and_extract(download_url)
107
- return [
108
- datasets.SplitGenerator(
109
- name=datasets.Split.TRAIN,
110
- gen_kwargs={"datapath": path},
111
- )
112
- ]
113
-
114
- def _generate_examples(self, datapath):
115
- l1, l2 = self.config.lang1, self.config.lang2
116
- folder = l1 + "-" + l2
117
- l1_file = _BASE_NAME.format(folder, l1)
118
- l2_file = _BASE_NAME.format(folder, l2)
119
- l1_path = os.path.join(datapath, l1_file)
120
- l2_path = os.path.join(datapath, l2_file)
121
- with open(l1_path, encoding="utf-8") as f1, open(l2_path, encoding="utf-8") as f2:
122
- for sentence_counter, (x, y) in enumerate(zip(f1, f2)):
123
- x = x.strip()
124
- y = y.strip()
125
- result = (
126
- sentence_counter,
127
- {
128
- "id": str(sentence_counter),
129
- "translation": {l1: x, l2: y},
130
- },
131
- )
132
- yield result