Datasets:
Delete loading script
Browse files- samanantar.py +0 -94
samanantar.py
DELETED
@@ -1,94 +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 |
-
"""Samanantar dataset."""
|
16 |
-
|
17 |
-
from pathlib import Path
|
18 |
-
|
19 |
-
import datasets
|
20 |
-
|
21 |
-
|
22 |
-
_CITATION = """\
|
23 |
-
@misc{ramesh2021samanantar,
|
24 |
-
title={Samanantar: The Largest Publicly Available Parallel Corpora Collection for 11 Indic Languages},
|
25 |
-
author={Gowtham Ramesh and Sumanth Doddapaneni and Aravinth Bheemaraj and Mayank Jobanputra and Raghavan AK and Ajitesh Sharma and Sujit Sahoo and Harshita Diddee and Mahalakshmi J and Divyanshu Kakwani and Navneet Kumar and Aswin Pradeep and Srihari Nagaraj and Kumar Deepak and Vivek Raghavan and Anoop Kunchukuttan and Pratyush Kumar and Mitesh Shantadevi Khapra},
|
26 |
-
year={2021},
|
27 |
-
eprint={2104.05596},
|
28 |
-
archivePrefix={arXiv},
|
29 |
-
primaryClass={cs.CL}
|
30 |
-
}
|
31 |
-
"""
|
32 |
-
|
33 |
-
_DESCRIPTION = """\
|
34 |
-
Samanantar is the largest publicly available parallel corpora collection for Indic languages: Assamese, Bengali, Gujarati, Hindi, Kannada, Malayalam, Marathi, Oriya, Punjabi, Tamil, Telugu. The corpus has 49.6M sentence pairs between English to Indian Languages.
|
35 |
-
"""
|
36 |
-
|
37 |
-
_HOMEPAGE = "https://indicnlp.ai4bharat.org/samanantar/"
|
38 |
-
|
39 |
-
_LICENSE = "Creative Commons Attribution-NonCommercial 4.0 International"
|
40 |
-
|
41 |
-
_URLS = {
|
42 |
-
"0.3.0": "https://objectstore.e2enetworks.net/ai4b-public-nlu-nlg/samanantar_paper_version.zip",
|
43 |
-
}
|
44 |
-
_LANGUAGES = ["as", "bn", "gu", "hi", "kn", "ml", "mr", "or", "pa", "ta", "te"]
|
45 |
-
|
46 |
-
|
47 |
-
class SamanantarConfig(datasets.BuilderConfig):
|
48 |
-
VERSION = datasets.Version("0.3.0")
|
49 |
-
|
50 |
-
def __init__(self, language=None, version=VERSION, **kwargs):
|
51 |
-
super().__init__(name=language, version=version, **kwargs)
|
52 |
-
self.language = language
|
53 |
-
|
54 |
-
|
55 |
-
class Samanantar(datasets.GeneratorBasedBuilder):
|
56 |
-
"""Samanantar dataset."""
|
57 |
-
|
58 |
-
BUILDER_CONFIG_CLASS = SamanantarConfig
|
59 |
-
BUILDER_CONFIGS = [SamanantarConfig(language=language) for language in _LANGUAGES]
|
60 |
-
|
61 |
-
def _info(self):
|
62 |
-
return datasets.DatasetInfo(
|
63 |
-
description=_DESCRIPTION,
|
64 |
-
features=datasets.Features(
|
65 |
-
{
|
66 |
-
"idx": datasets.Value("int64"),
|
67 |
-
"src": datasets.Value("string"),
|
68 |
-
"tgt": datasets.Value("string"),
|
69 |
-
}
|
70 |
-
),
|
71 |
-
supervised_keys=None,
|
72 |
-
homepage=_HOMEPAGE,
|
73 |
-
license=_LICENSE,
|
74 |
-
citation=_CITATION,
|
75 |
-
)
|
76 |
-
|
77 |
-
def _split_generators(self, dl_manager):
|
78 |
-
urls = _URLS[str(self.config.version)]
|
79 |
-
data_dir = dl_manager.download_and_extract(urls)
|
80 |
-
return [
|
81 |
-
datasets.SplitGenerator(
|
82 |
-
name=datasets.Split.TRAIN,
|
83 |
-
gen_kwargs={
|
84 |
-
"data_dir": (Path(data_dir) / "samanantar_paper_version" / f"en-{self.config.language}"),
|
85 |
-
},
|
86 |
-
),
|
87 |
-
]
|
88 |
-
|
89 |
-
def _generate_examples(self, data_dir):
|
90 |
-
src_path = data_dir / "train.en"
|
91 |
-
tgt_path = data_dir / f"train.{self.config.language}"
|
92 |
-
with src_path.open(encoding="utf-8") as src_file, tgt_path.open(encoding="utf-8") as tgt_file:
|
93 |
-
for idx, (src_line, tgt_line) in enumerate(zip(src_file, tgt_file)):
|
94 |
-
yield idx, {"idx": idx, "src": src_line.strip(), "tgt": tgt_line.strip()}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|