Datasets:

Modalities:
Text
Formats:
parquet
Libraries:
Datasets
pandas
License:
albertvillanova HF staff commited on
Commit
29b84ce
1 Parent(s): 1bb81d5

Delete loading script

Browse files
Files changed (1) hide show
  1. opus_infopankki.py +0 -97
opus_infopankki.py DELETED
@@ -1,97 +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
- """A parallel corpus of 12 languages, 66 bitexts."""
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 parallel corpus of 12 languages, 66 bitexts.
43
- """
44
-
45
-
46
- _HOMEPAGE = "https://opus.nlpl.eu/infopankki/corpus/version/infopankki"
47
-
48
- _LANGUAGES = ["ar", "en", "es", "et", "fa", "fi", "fr", "ru", "so", "sv", "tr", "zh"]
49
- _LANGUAGE_PAIRS = list(itertools.combinations(_LANGUAGES, 2))
50
-
51
- _BASE_URL = "https://object.pouta.csc.fi/OPUS-infopankki/v1/moses"
52
- _URLS = {f"{l1}-{l2}": f"{_BASE_URL}/{l1}-{l2}.txt.zip" for l1, l2 in _LANGUAGE_PAIRS}
53
-
54
-
55
- class OpusInfopankki(datasets.GeneratorBasedBuilder):
56
- """A parallel corpus of 12 languages, 66 bitexts."""
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"OpusInfopankki {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"infopankki.{self.config.name}.{lang_pair[0]}"),
87
- "target_file": os.path.join(data_dir, f"infopankki.{self.config.name}.{lang_pair[1]}"),
88
- },
89
- ),
90
- ]
91
-
92
- def _generate_examples(self, source_file, target_file):
93
- source, target = tuple(self.config.name.split("-"))
94
- with open(source_file, encoding="utf-8") as src_f, open(target_file, encoding="utf-8") as tgt_f:
95
- for idx, (l1, l2) in enumerate(zip(src_f, tgt_f)):
96
- result = {"translation": {source: l1.strip(), target: l2.strip()}}
97
- yield idx, result