albertvillanova HF staff commited on
Commit
2be1b1b
1 Parent(s): 08c95a7

Delete loading script

Browse files
Files changed (1) hide show
  1. opus_openoffice.py +0 -108
opus_openoffice.py DELETED
@@ -1,108 +0,0 @@
1
- # coding=utf-8
2
- # Copyright 2020 The 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
- """OpusOpenoffice: A collection of documents from openoffice org"""
16
-
17
-
18
- import itertools
19
- import os
20
-
21
- import datasets
22
-
23
-
24
- _CITATION = """\
25
- @InProceedings{TIEDEMANN12.463,
26
- author = {J�rg Tiedemann},
27
- title = {Parallel Data, Tools and Interfaces in OPUS},
28
- booktitle = {Proceedings of the Eight International Conference on Language Resources and Evaluation (LREC'12)},
29
- year = {2012},
30
- month = {may},
31
- date = {23-25},
32
- address = {Istanbul, Turkey},
33
- 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},
34
- publisher = {European Language Resources Association (ELRA)},
35
- isbn = {978-2-9517408-7-7},
36
- language = {english}
37
- }
38
- """
39
-
40
-
41
- _DESCRIPTION = """\
42
- A collection of documents from http://www.openoffice.org/.
43
- """
44
-
45
-
46
- _HOMEPAGE = "https://opus.nlpl.eu/OpenOffice/corpus/version/OpenOffice"
47
-
48
- _LANGUAGES = ["de", "en_GB", "es", "fr", "ja", "ru", "sv", "zh_CN"]
49
- _LANGUAGE_PAIRS = list(itertools.combinations(_LANGUAGES, 2))
50
-
51
- _BASE_URL = "https://object.pouta.csc.fi/OPUS-OpenOffice/v3/moses"
52
- _URLS = {f"{l1}-{l2}": f"{_BASE_URL}/{l1}-{l2}.txt.zip" for l1, l2 in _LANGUAGE_PAIRS}
53
-
54
-
55
- class OpusOpenoffice(datasets.GeneratorBasedBuilder):
56
- """OpusOpenoffice: A collection of documents from openoffice org"""
57
-
58
- VERSION = datasets.Version("1.0.0")
59
-
60
- BUILDER_CONFIGS = [
61
- datasets.BuilderConfig(
62
- name=f"{l1}-{l2}", version=datasets.Version("1.0.0"), description=f"OPUS EUconst {l1}-{l2}"
63
- )
64
- for l1, l2 in _LANGUAGE_PAIRS
65
- ]
66
-
67
- def _info(self):
68
- return datasets.DatasetInfo(
69
- description=_DESCRIPTION,
70
- features=datasets.Features(
71
- {"translation": datasets.features.Translation(languages=tuple(self.config.name.split("-")))}
72
- ),
73
- supervised_keys=None,
74
- homepage=_HOMEPAGE,
75
- citation=_CITATION,
76
- )
77
-
78
- def _split_generators(self, dl_manager):
79
- """Returns SplitGenerators."""
80
- lang_pair = self.config.name.split("-")
81
- data_dir = dl_manager.download_and_extract(_URLS[self.config.name])
82
- return [
83
- datasets.SplitGenerator(
84
- name=datasets.Split.TRAIN,
85
- gen_kwargs={
86
- "source_file": os.path.join(data_dir, f"OpenOffice.{self.config.name}.{lang_pair[0]}"),
87
- "target_file": os.path.join(data_dir, f"OpenOffice.{self.config.name}.{lang_pair[1]}"),
88
- },
89
- ),
90
- ]
91
-
92
- def _generate_examples(self, source_file, target_file):
93
- with open(source_file, encoding="utf-8") as f:
94
- source_sentences = f.read().split("\n")
95
- with open(target_file, encoding="utf-8") as f:
96
- target_sentences = f.read().split("\n")
97
-
98
- assert len(target_sentences) == len(source_sentences), "Sizes do not match: %d vs %d for %s vs %s." % (
99
- len(source_sentences),
100
- len(target_sentences),
101
- source_file,
102
- target_file,
103
- )
104
-
105
- source, target = tuple(self.config.name.split("-"))
106
- for idx, (l1, l2) in enumerate(zip(source_sentences, target_sentences)):
107
- result = {"translation": {source: l1, target: l2}}
108
- yield idx, result