albertvillanova HF staff commited on
Commit
08ae41a
1 Parent(s): 45bc026

Delete loading script

Browse files
Files changed (1) hide show
  1. opus_xhosanavy.py +0 -88
opus_xhosanavy.py DELETED
@@ -1,88 +0,0 @@
1
- # coding=utf-8
2
- # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
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
- """XhosaNavy English -Xhosa"""
16
-
17
-
18
- import os
19
-
20
- import datasets
21
-
22
-
23
- _CITATION = """\
24
- J. Tiedemann, 2012, Parallel Data, Tools and Interfaces in OPUS. In Proceedings of the 8th International \
25
- Conference on Language Resources and Evaluation (LREC 2012)"""
26
-
27
- _HOMEPAGE = "http://opus.nlpl.eu/XhosaNavy-v1.php"
28
-
29
-
30
- _LICENSE = ""
31
-
32
- _DESCRIPTION = """\
33
- This dataset is designed for machine translation from English to Xhosa."""
34
-
35
-
36
- _URLs = {"train": "https://object.pouta.csc.fi/OPUS-XhosaNavy/v1/moses/en-xh.txt.zip"}
37
-
38
-
39
- class OpusXhosanavy(datasets.GeneratorBasedBuilder):
40
-
41
- VERSION = datasets.Version("1.0.0")
42
-
43
- BUILDER_CONFIGS = [datasets.BuilderConfig(name="en-xh", version=VERSION, description="XhosaNavy English -Xhosa")]
44
-
45
- def _info(self):
46
- return datasets.DatasetInfo(
47
- description=_DESCRIPTION,
48
- features=datasets.Features(
49
- {"translation": datasets.features.Translation(languages=tuple(self.config.name.split("-")))}
50
- ),
51
- supervised_keys=None,
52
- homepage="http://opus.nlpl.eu/XhosaNavy-v1.php",
53
- citation=_CITATION,
54
- )
55
-
56
- def _split_generators(self, dl_manager):
57
- """Returns SplitGenerators."""
58
- data_dir = dl_manager.download_and_extract(_URLs)
59
- return [
60
- datasets.SplitGenerator(
61
- name=datasets.Split.TRAIN,
62
- # These kwargs will be passed to _generate_examples
63
- gen_kwargs={
64
- "source_file": os.path.join(data_dir["train"], "XhosaNavy.en-xh.en"),
65
- "target_file": os.path.join(data_dir["train"], "XhosaNavy.en-xh.xh"),
66
- "split": "train",
67
- },
68
- ),
69
- ]
70
-
71
- def _generate_examples(self, source_file, target_file, split):
72
- """This function returns the examples in the raw (text) form."""
73
- with open(source_file, encoding="utf-8") as f:
74
- source_sentences = f.read().split("\n")
75
- with open(target_file, encoding="utf-8") as f:
76
- target_sentences = f.read().split("\n")
77
-
78
- assert len(target_sentences) == len(source_sentences), "Sizes do not match: %d vs %d for %s vs %s." % (
79
- len(source_sentences),
80
- len(target_sentences),
81
- source_file,
82
- target_file,
83
- )
84
-
85
- source, target = tuple(self.config.name.split("-"))
86
- for idx, (l1, l2) in enumerate(zip(source_sentences, target_sentences)):
87
- result = {"translation": {source: l1, target: l2}}
88
- yield idx, result