velkadamban commited on
Commit
10969c8
1 Parent(s): 81d22af

Update TamilSamanantar.py

Browse files
Files changed (1) hide show
  1. TamilSamanantar.py +94 -92
TamilSamanantar.py CHANGED
@@ -1,92 +1,94 @@
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 - Tamil."""
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. This dataset specifically contains parallel corpora between English and Tamil.
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://ai4b-my.sharepoint.com/:u:/g/personal/sumanthdoddapaneni_ai4bharat_org/EXhX84sbTQhLrsURCU9DlUwBVyJ10cYK9bQQe1SMljf_yA?e=q7GJpb&download=1",
43
- }
44
-
45
-
46
- class SamanantarTamilConfig(datasets.BuilderConfig):
47
- VERSION = datasets.Version("0.3.0")
48
-
49
- def __init__(self, version=VERSION, **kwargs):
50
- super().__init__(name="ta", version=version, **kwargs)
51
-
52
-
53
- class SamanantarTamil(datasets.GeneratorBasedBuilder):
54
- """Samanantar Tamil dataset."""
55
-
56
- BUILDER_CONFIG_CLASS = SamanantarTamilConfig
57
- BUILDER_CONFIGS = [SamanantarTamilConfig()]
58
-
59
- def _info(self):
60
- return datasets.DatasetInfo(
61
- description=_DESCRIPTION,
62
- features=datasets.Features(
63
- {
64
- "idx": datasets.Value("int64"),
65
- "src": datasets.Value("string"),
66
- "tgt": datasets.Value("string"),
67
- }
68
- ),
69
- supervised_keys=None,
70
- homepage=_HOMEPAGE,
71
- license=_LICENSE,
72
- citation=_CITATION,
73
- )
74
-
75
- def _split_generators(self, dl_manager):
76
- urls = _URLS[str(self.config.version)]
77
- data_dir = dl_manager.download_and_extract(urls)
78
- return [
79
- datasets.SplitGenerator(
80
- name=datasets.Split.TRAIN,
81
- gen_kwargs={
82
- "data_dir": (Path(data_dir) / "v2" / "en-ta"),
83
- },
84
- ),
85
- ]
86
-
87
- def _generate_examples(self, data_dir):
88
- src_path = data_dir / "train.en"
89
- tgt_path = data_dir / "train.ta"
90
- with src_path.open(encoding="utf-8") as src_file, tgt_path.open(encoding="utf-8") as tgt_file:
91
- for idx, (src_line, tgt_line) in enumerate(zip(src_file, tgt_file)):
92
- yield idx, {"idx": idx, "src": src_line.strip(), "tgt": tgt_line.strip()}
 
 
 
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. This dataset specifically contains parallel corpora between English and Tamil.
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://ai4b-my.sharepoint.com/:u:/g/personal/sumanthdoddapaneni_ai4bharat_org/EXhX84sbTQhLrsURCU9DlUwBVyJ10cYK9bQQe1SMljf_yA?e=q7GJpb&download=1",
43
+ }
44
+ _LANGUAGES = ["ta"]
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) / "v2" / 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()}