Datasets:
Delete loading script
Browse files- hrenwac_para.py +0 -91
hrenwac_para.py
DELETED
@@ -1,91 +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 |
-
"""Croatian-English parallel corpus hrenWaC"""
|
16 |
-
|
17 |
-
import datasets
|
18 |
-
|
19 |
-
|
20 |
-
_CITATION = """
|
21 |
-
@misc{11356/1058,
|
22 |
-
title = {Croatian-English parallel corpus {hrenWaC} 2.0},
|
23 |
-
author = {Ljube{\v s}i{\'c}, Nikola and Espl{\'a}-Gomis, Miquel and Ortiz Rojas, Sergio and Klubi{\v c}ka, Filip and Toral, Antonio},
|
24 |
-
url = {http://hdl.handle.net/11356/1058},
|
25 |
-
note = {Slovenian language resource repository {CLARIN}.{SI}},
|
26 |
-
copyright = {{CLARIN}.{SI} User Licence for Internet Corpora},
|
27 |
-
year = {2016} }
|
28 |
-
"""
|
29 |
-
|
30 |
-
_DESCRIPTION = """
|
31 |
-
The hrenWaC corpus version 2.0 consists of parallel Croatian-English texts crawled from the .hr top-level domain for Croatia.
|
32 |
-
The corpus was built with Spidextor (https://github.com/abumatran/spidextor), a tool that glues together the output of SpiderLing used for crawling and Bitextor used for bitext extraction. The accuracy of the extracted bitext on the segment level is around 80% and on the word level around 84%.
|
33 |
-
"""
|
34 |
-
|
35 |
-
_LICENSE = "CC BY-SA 3.0"
|
36 |
-
|
37 |
-
_HOMEPAGE = "http://nlp.ffzg.hr/resources/corpora/hrenwac/"
|
38 |
-
_URLS = "http://nlp.ffzg.hr/data/corpora/hrenwac/hrenwac.en-hr.txt.gz"
|
39 |
-
|
40 |
-
|
41 |
-
class HrenwacPara(datasets.GeneratorBasedBuilder):
|
42 |
-
"""Croatian-English parallel corpus hrenWaC"""
|
43 |
-
|
44 |
-
VERSION = datasets.Version("1.0.0")
|
45 |
-
BUILDER_CONFIGS = [
|
46 |
-
datasets.BuilderConfig(
|
47 |
-
name="hrenWaC",
|
48 |
-
version=VERSION,
|
49 |
-
description="The hrenWaC dataset.",
|
50 |
-
),
|
51 |
-
]
|
52 |
-
|
53 |
-
def _info(self):
|
54 |
-
return datasets.DatasetInfo(
|
55 |
-
description=_DESCRIPTION,
|
56 |
-
features=datasets.Features({"translation": datasets.features.Translation(languages=("en", "hr"))}),
|
57 |
-
supervised_keys=("en", "hr"),
|
58 |
-
homepage=_HOMEPAGE,
|
59 |
-
license=_LICENSE,
|
60 |
-
citation=_CITATION,
|
61 |
-
)
|
62 |
-
|
63 |
-
def _split_generators(self, dl_manager):
|
64 |
-
downloaded_file = dl_manager.download_and_extract({"train": _URLS})
|
65 |
-
return [
|
66 |
-
datasets.SplitGenerator(
|
67 |
-
name=datasets.Split.TRAIN,
|
68 |
-
gen_kwargs={
|
69 |
-
"filepath": downloaded_file["train"],
|
70 |
-
},
|
71 |
-
),
|
72 |
-
]
|
73 |
-
|
74 |
-
def _generate_examples(self, filepath):
|
75 |
-
with open(filepath, encoding="utf8") as f:
|
76 |
-
en = ""
|
77 |
-
hr = ""
|
78 |
-
i = -1
|
79 |
-
for id_, row in enumerate(f):
|
80 |
-
if id_ % 3 == 0:
|
81 |
-
en = row.strip()
|
82 |
-
if id_ % 3 == 1:
|
83 |
-
hr = row.strip()
|
84 |
-
if id_ % 3 == 2:
|
85 |
-
i = i + 1
|
86 |
-
yield i, {
|
87 |
-
"translation": {
|
88 |
-
"en": en,
|
89 |
-
"hr": hr,
|
90 |
-
}
|
91 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|