Datasets:

Multilinguality:
multilingual
Size Categories:
10K<n<100K
Language Creators:
found
Annotations Creators:
found
Source Datasets:
original
Tags:
License:
albertvillanova HF staff commited on
Commit
b53301f
1 Parent(s): 17372a4

Delete loading script

Browse files
Files changed (1) hide show
  1. opus_euconst.py +0 -119
opus_euconst.py DELETED
@@ -1,119 +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
- """Euroconst: A parallel corpus collected from the European Constitution for 21 language"""
16
-
17
-
18
- import itertools
19
- import os
20
-
21
- import datasets
22
-
23
-
24
- _CITATION = """\
25
- J. Tiedemann, 2012, Parallel Data, Tools and Interfaces in OPUS. \
26
- In Proceedings of the 8th International Conference on Language Resources and Evaluation (LREC 2012)
27
- """
28
-
29
-
30
- _DESCRIPTION = """\
31
- A parallel corpus collected from the European Constitution for 21 language.
32
- """
33
-
34
-
35
- _HOMEPAGE = "https://opus.nlpl.eu/EUconst/corpus/version/EUconst"
36
-
37
- _LANGUAGES = [
38
- "cs",
39
- "da",
40
- "de",
41
- "el",
42
- "en",
43
- "es",
44
- "et",
45
- "fi",
46
- "fr",
47
- "ga",
48
- "hu",
49
- "it",
50
- "lt",
51
- "lv",
52
- "mt",
53
- "nl",
54
- "pl",
55
- "pt",
56
- "sk",
57
- "sl",
58
- "sv",
59
- ]
60
- _LANGUAGE_PAIRS = list(itertools.combinations(_LANGUAGES, 2))
61
-
62
- _BASE_URL = "https://object.pouta.csc.fi/OPUS-EUconst/v1/moses"
63
- _URLS = {f"{l1}-{l2}": f"{_BASE_URL}/{l1}-{l2}.txt.zip" for l1, l2 in _LANGUAGE_PAIRS}
64
-
65
-
66
- class OpusEuconst(datasets.GeneratorBasedBuilder):
67
- """Euroconst: A parallel corpus collected from the European Constitution for 21 language"""
68
-
69
- VERSION = datasets.Version("1.0.0")
70
-
71
- BUILDER_CONFIGS = [
72
- datasets.BuilderConfig(
73
- name=f"{l1}-{l2}", version=datasets.Version("1.0.0"), description=f"OPUS EUconst {l1}-{l2}"
74
- )
75
- for l1, l2 in _LANGUAGE_PAIRS
76
- ]
77
-
78
- def _info(self):
79
- return datasets.DatasetInfo(
80
- description=_DESCRIPTION,
81
- features=datasets.Features(
82
- {"translation": datasets.features.Translation(languages=tuple(self.config.name.split("-")))}
83
- ),
84
- supervised_keys=None,
85
- homepage=_HOMEPAGE,
86
- citation=_CITATION,
87
- )
88
-
89
- def _split_generators(self, dl_manager):
90
- """Returns SplitGenerators."""
91
- lang_pair = self.config.name.split("-")
92
- data_dir = dl_manager.download_and_extract(_URLS[self.config.name])
93
- return [
94
- datasets.SplitGenerator(
95
- name=datasets.Split.TRAIN,
96
- gen_kwargs={
97
- "source_file": os.path.join(data_dir, f"EUconst.{self.config.name}.{lang_pair[0]}"),
98
- "target_file": os.path.join(data_dir, f"EUconst.{self.config.name}.{lang_pair[1]}"),
99
- },
100
- ),
101
- ]
102
-
103
- def _generate_examples(self, source_file, target_file):
104
- with open(source_file, encoding="utf-8") as f:
105
- source_sentences = f.read().split("\n")
106
- with open(target_file, encoding="utf-8") as f:
107
- target_sentences = f.read().split("\n")
108
-
109
- assert len(target_sentences) == len(source_sentences), "Sizes do not match: %d vs %d for %s vs %s." % (
110
- len(source_sentences),
111
- len(target_sentences),
112
- source_file,
113
- target_file,
114
- )
115
-
116
- source, target = tuple(self.config.name.split("-"))
117
- for idx, (l1, l2) in enumerate(zip(source_sentences, target_sentences)):
118
- result = {"translation": {source: l1, target: l2}}
119
- yield idx, result