Datasets:
Delete loading script
Browse files- eitb_parcc.py +0 -132
eitb_parcc.py
DELETED
|
@@ -1,132 +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 |
-
"""EiTB-ParCC: Parallel Corpus of Comparable News"""
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
import os
|
| 19 |
-
|
| 20 |
-
import datasets
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
_CITATION = """\
|
| 24 |
-
@inproceedings{etchegoyhen-gete-2020-handle,
|
| 25 |
-
title = "Handle with Care: A Case Study in Comparable Corpora Exploitation for Neural Machine Translation",
|
| 26 |
-
author = "Etchegoyhen, Thierry and
|
| 27 |
-
Gete, Harritxu",
|
| 28 |
-
editor = "Calzolari, Nicoletta and
|
| 29 |
-
B{\'e}chet, Fr{\'e}d{\'e}ric and
|
| 30 |
-
Blache, Philippe and
|
| 31 |
-
Choukri, Khalid and
|
| 32 |
-
Cieri, Christopher and
|
| 33 |
-
Declerck, Thierry and
|
| 34 |
-
Goggi, Sara and
|
| 35 |
-
Isahara, Hitoshi and
|
| 36 |
-
Maegaard, Bente and
|
| 37 |
-
Mariani, Joseph and
|
| 38 |
-
Mazo, H{\'e}l{\`e}ne and
|
| 39 |
-
Moreno, Asuncion and
|
| 40 |
-
Odijk, Jan and
|
| 41 |
-
Piperidis, Stelios",
|
| 42 |
-
booktitle = "Proceedings of the Twelfth Language Resources and Evaluation Conference",
|
| 43 |
-
month = may,
|
| 44 |
-
year = "2020",
|
| 45 |
-
address = "Marseille, France",
|
| 46 |
-
publisher = "European Language Resources Association",
|
| 47 |
-
url = "https://aclanthology.org/2020.lrec-1.469",
|
| 48 |
-
pages = "3799--3807",
|
| 49 |
-
language = "English",
|
| 50 |
-
ISBN = "979-10-95546-34-4",
|
| 51 |
-
}
|
| 52 |
-
@InProceedings{TIEDEMANN12.463,
|
| 53 |
-
author = {J{\"o}rg Tiedemann},
|
| 54 |
-
title = {Parallel Data, Tools and Interfaces in OPUS},
|
| 55 |
-
booktitle = {Proceedings of the Eight International Conference on Language Resources and Evaluation (LREC'12)},
|
| 56 |
-
year = {2012},
|
| 57 |
-
month = {may},
|
| 58 |
-
date = {23-25},
|
| 59 |
-
address = {Istanbul, Turkey},
|
| 60 |
-
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},
|
| 61 |
-
publisher = {European Language Resources Association (ELRA)},
|
| 62 |
-
isbn = {978-2-9517408-7-7},
|
| 63 |
-
language = {english}
|
| 64 |
-
}
|
| 65 |
-
"""
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
_DESCRIPTION = """\
|
| 69 |
-
EiTB-ParCC: Parallel Corpus of Comparable News. A Basque-Spanish parallel corpus provided by \
|
| 70 |
-
Vicomtech (https://www.vicomtech.org), extracted from comparable news produced by the \
|
| 71 |
-
Basque public broadcasting group Euskal Irrati Telebista.
|
| 72 |
-
"""
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
_HOMEPAGE = "https://opus.nlpl.eu/EiTB-ParCC/corpus/version/EiTB-ParCC"
|
| 76 |
-
|
| 77 |
-
_URL = "https://object.pouta.csc.fi/OPUS-EiTB-ParCC/v1/moses/es-eu.txt.zip"
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
class EitbParcc(datasets.GeneratorBasedBuilder):
|
| 81 |
-
"""EiTB-ParCC: Parallel Corpus of Comparable News"""
|
| 82 |
-
|
| 83 |
-
VERSION = datasets.Version("1.0.0")
|
| 84 |
-
|
| 85 |
-
BUILDER_CONFIGS = [
|
| 86 |
-
datasets.BuilderConfig(
|
| 87 |
-
name="es-eu", version=datasets.Version("1.0.0"), description="A Basque-Spanish parallel"
|
| 88 |
-
)
|
| 89 |
-
]
|
| 90 |
-
|
| 91 |
-
def _info(self):
|
| 92 |
-
return datasets.DatasetInfo(
|
| 93 |
-
description=_DESCRIPTION,
|
| 94 |
-
features=datasets.Features(
|
| 95 |
-
{"translation": datasets.features.Translation(languages=tuple(self.config.name.split("-")))}
|
| 96 |
-
),
|
| 97 |
-
supervised_keys=None,
|
| 98 |
-
homepage=_HOMEPAGE,
|
| 99 |
-
citation=_CITATION,
|
| 100 |
-
)
|
| 101 |
-
|
| 102 |
-
def _split_generators(self, dl_manager):
|
| 103 |
-
"""Returns SplitGenerators."""
|
| 104 |
-
lang_pair = self.config.name.split("-")
|
| 105 |
-
data_dir = dl_manager.download_and_extract(_URL)
|
| 106 |
-
return [
|
| 107 |
-
datasets.SplitGenerator(
|
| 108 |
-
name=datasets.Split.TRAIN,
|
| 109 |
-
gen_kwargs={
|
| 110 |
-
"source_file": os.path.join(data_dir, f"EiTB-ParCC.{self.config.name}.{lang_pair[0]}"),
|
| 111 |
-
"target_file": os.path.join(data_dir, f"EiTB-ParCC.{self.config.name}.{lang_pair[1]}"),
|
| 112 |
-
},
|
| 113 |
-
),
|
| 114 |
-
]
|
| 115 |
-
|
| 116 |
-
def _generate_examples(self, source_file, target_file):
|
| 117 |
-
with open(source_file, encoding="utf-8") as f:
|
| 118 |
-
source_sentences = f.read().split("\n")
|
| 119 |
-
with open(target_file, encoding="utf-8") as f:
|
| 120 |
-
target_sentences = f.read().split("\n")
|
| 121 |
-
|
| 122 |
-
assert len(target_sentences) == len(source_sentences), "Sizes do not match: %d vs %d for %s vs %s." % (
|
| 123 |
-
len(source_sentences),
|
| 124 |
-
len(target_sentences),
|
| 125 |
-
source_file,
|
| 126 |
-
target_file,
|
| 127 |
-
)
|
| 128 |
-
|
| 129 |
-
source, target = tuple(self.config.name.split("-"))
|
| 130 |
-
for idx, (l1, l2) in enumerate(zip(source_sentences, target_sentences)):
|
| 131 |
-
result = {"translation": {source: l1, target: l2}}
|
| 132 |
-
yield idx, result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|