Datasets:
Commit
•
b73cd50
0
Parent(s):
Update files from the datasets library (from 1.2.0)
Browse filesRelease notes: https://github.com/huggingface/datasets/releases/tag/1.2.0
- .gitattributes +27 -0
- README.md +141 -0
- dataset_infos.json +1 -0
- dummy/all/1.0.0/dummy_data.zip +3 -0
- dummy/bible/1.0.0/dummy_data.zip +3 -0
- dummy/quran/1.0.0/dummy_data.zip +3 -0
- um005.py +149 -0
.gitattributes
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bin.* filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
20 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
26 |
+
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
annotations_creators:
|
3 |
+
- no-annotation
|
4 |
+
language_creators:
|
5 |
+
- other
|
6 |
+
languages:
|
7 |
+
- en
|
8 |
+
- ur
|
9 |
+
licenses:
|
10 |
+
- unknown
|
11 |
+
multilinguality:
|
12 |
+
- multilingual
|
13 |
+
size_categories:
|
14 |
+
- 1K<n<10K
|
15 |
+
source_datasets:
|
16 |
+
- original
|
17 |
+
task_categories:
|
18 |
+
- conditional-text-generation
|
19 |
+
task_ids:
|
20 |
+
- machine-translation
|
21 |
+
---
|
22 |
+
|
23 |
+
# Dataset Card Creation Guide
|
24 |
+
|
25 |
+
## Table of Contents
|
26 |
+
- [Dataset Description](#dataset-description)
|
27 |
+
- [Dataset Summary](#dataset-summary)
|
28 |
+
- [Supported Tasks](#supported-tasks-and-leaderboards)
|
29 |
+
- [Languages](#languages)
|
30 |
+
- [Dataset Structure](#dataset-structure)
|
31 |
+
- [Data Instances](#data-instances)
|
32 |
+
- [Data Fields](#data-instances)
|
33 |
+
- [Data Splits](#data-instances)
|
34 |
+
- [Dataset Creation](#dataset-creation)
|
35 |
+
- [Curation Rationale](#curation-rationale)
|
36 |
+
- [Source Data](#source-data)
|
37 |
+
- [Annotations](#annotations)
|
38 |
+
- [Personal and Sensitive Information](#personal-and-sensitive-information)
|
39 |
+
- [Considerations for Using the Data](#considerations-for-using-the-data)
|
40 |
+
- [Social Impact of Dataset](#social-impact-of-dataset)
|
41 |
+
- [Discussion of Biases](#discussion-of-biases)
|
42 |
+
- [Other Known Limitations](#other-known-limitations)
|
43 |
+
- [Additional Information](#additional-information)
|
44 |
+
- [Dataset Curators](#dataset-curators)
|
45 |
+
- [Licensing Information](#licensing-information)
|
46 |
+
- [Citation Information](#citation-information)
|
47 |
+
|
48 |
+
## Dataset Description
|
49 |
+
|
50 |
+
- **Homepage:** http://ufal.ms.mff.cuni.cz/umc/005-en-ur/
|
51 |
+
- **Repository:** None
|
52 |
+
- **Paper:** https://www.researchgate.net/publication/268008206_Word-Order_Issues_in_English-to-Urdu_Statistical_Machine_Translation
|
53 |
+
- **Leaderboard:** [If the dataset supports an active leaderboard, add link here]()
|
54 |
+
- **Point of Contact:** Bushra Jawaid and Daniel Zeman
|
55 |
+
|
56 |
+
### Dataset Summary
|
57 |
+
|
58 |
+
[More Information Needed]
|
59 |
+
|
60 |
+
### Supported Tasks and Leaderboards
|
61 |
+
|
62 |
+
[More Information Needed]
|
63 |
+
|
64 |
+
### Languages
|
65 |
+
|
66 |
+
[More Information Needed]
|
67 |
+
|
68 |
+
## Dataset Structure
|
69 |
+
|
70 |
+
### Data Instances
|
71 |
+
|
72 |
+
[More Information Needed]
|
73 |
+
|
74 |
+
### Data Fields
|
75 |
+
|
76 |
+
[More Information Needed]
|
77 |
+
|
78 |
+
### Data Splits
|
79 |
+
|
80 |
+
[More Information Needed]
|
81 |
+
## Dataset Creation
|
82 |
+
|
83 |
+
### Curation Rationale
|
84 |
+
|
85 |
+
[More Information Needed]
|
86 |
+
|
87 |
+
### Source Data
|
88 |
+
|
89 |
+
[More Information Needed]
|
90 |
+
|
91 |
+
#### Initial Data Collection and Normalization
|
92 |
+
|
93 |
+
[More Information Needed]
|
94 |
+
|
95 |
+
#### Who are the source language producers?
|
96 |
+
|
97 |
+
[More Information Needed]
|
98 |
+
|
99 |
+
### Annotations
|
100 |
+
|
101 |
+
[More Information Needed]
|
102 |
+
|
103 |
+
#### Annotation process
|
104 |
+
|
105 |
+
[More Information Needed]
|
106 |
+
|
107 |
+
#### Who are the annotators?
|
108 |
+
|
109 |
+
[More Information Needed]
|
110 |
+
|
111 |
+
### Personal and Sensitive Information
|
112 |
+
|
113 |
+
[More Information Needed]
|
114 |
+
|
115 |
+
## Considerations for Using the Data
|
116 |
+
|
117 |
+
### Social Impact of Dataset
|
118 |
+
|
119 |
+
[More Information Needed]
|
120 |
+
|
121 |
+
### Discussion of Biases
|
122 |
+
|
123 |
+
[More Information Needed]
|
124 |
+
|
125 |
+
### Other Known Limitations
|
126 |
+
|
127 |
+
[More Information Needed]
|
128 |
+
|
129 |
+
## Additional Information
|
130 |
+
|
131 |
+
### Dataset Curators
|
132 |
+
|
133 |
+
[More Information Needed]
|
134 |
+
|
135 |
+
### Licensing Information
|
136 |
+
|
137 |
+
[More Information Needed]
|
138 |
+
|
139 |
+
### Citation Information
|
140 |
+
|
141 |
+
[More Information Needed]
|
dataset_infos.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"bible": {"description": "UMC005 English-Urdu is a parallel corpus of texts in English and Urdu language with sentence alignments. The corpus can be used for experiments with statistical machine translation.\n\nThe texts come from four different sources:\n- Quran\n- Bible\n- Penn Treebank (Wall Street Journal)\n- Emille corpus\n\nThe authors provide the religious texts of Quran and Bible for direct download. Because of licensing reasons, Penn and Emille texts cannot be redistributed freely. However, if you already hold a license for the original corpora, we are able to provide scripts that will recreate our data on your disk. Our modifications include but are not limited to the following:\n\n- Correction of Urdu translations and manual sentence alignment of the Emille texts.\n- Manually corrected sentence alignment of the other corpora.\n- Our data split (training-development-test) so that our published experiments can be reproduced.\n- Tokenization (optional, but needed to reproduce our experiments).\n- Normalization (optional) of e.g. European vs. Urdu numerals, European vs. Urdu punctuation, removal of Urdu diacritics.\n", "citation": "@unpublished{JaZeWordOrderIssues2011,\nauthor = {Bushra Jawaid and Daniel Zeman},\ntitle = {Word-Order Issues in {English}-to-{Urdu} Statistical Machine Translation},\nyear = {2011},\njournal = {The Prague Bulletin of Mathematical Linguistics},\nnumber = {95},\ninstitution = {Univerzita Karlova},\naddress = {Praha, Czechia},\nissn = {0032-6585},\n}\n", "homepage": "http://ufal.ms.mff.cuni.cz/umc/005-en-ur/", "license": "", "features": {"id": {"dtype": "string", "id": null, "_type": "Value"}, "translation": {"languages": ["ur", "en"], "id": null, "_type": "Translation"}}, "post_processed": null, "supervised_keys": null, "builder_name": "u_m005", "config_name": "bible", "version": {"version_str": "1.0.0", "description": "", "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 2350730, "num_examples": 7400, "dataset_name": "u_m005"}, "validation": {"name": "validation", "num_bytes": 113476, "num_examples": 300, "dataset_name": "u_m005"}, "test": {"name": "test", "num_bytes": 104678, "num_examples": 257, "dataset_name": "u_m005"}}, "download_checksums": {"http://ufal.ms.mff.cuni.cz/umc/005-en-ur/download.php?f=umc005-corpus.zip": {"num_bytes": 3683565, "checksum": "6c09c759125c513ee16f06705475140e7738eae5c01c3d7a1198582e9f5a0998"}}, "download_size": 3683565, "post_processing_size": null, "dataset_size": 2568884, "size_in_bytes": 6252449}, "quran": {"description": "UMC005 English-Urdu is a parallel corpus of texts in English and Urdu language with sentence alignments. The corpus can be used for experiments with statistical machine translation.\n\nThe texts come from four different sources:\n- Quran\n- Bible\n- Penn Treebank (Wall Street Journal)\n- Emille corpus\n\nThe authors provide the religious texts of Quran and Bible for direct download. Because of licensing reasons, Penn and Emille texts cannot be redistributed freely. However, if you already hold a license for the original corpora, we are able to provide scripts that will recreate our data on your disk. Our modifications include but are not limited to the following:\n\n- Correction of Urdu translations and manual sentence alignment of the Emille texts.\n- Manually corrected sentence alignment of the other corpora.\n- Our data split (training-development-test) so that our published experiments can be reproduced.\n- Tokenization (optional, but needed to reproduce our experiments).\n- Normalization (optional) of e.g. European vs. Urdu numerals, European vs. Urdu punctuation, removal of Urdu diacritics.\n", "citation": "@unpublished{JaZeWordOrderIssues2011,\nauthor = {Bushra Jawaid and Daniel Zeman},\ntitle = {Word-Order Issues in {English}-to-{Urdu} Statistical Machine Translation},\nyear = {2011},\njournal = {The Prague Bulletin of Mathematical Linguistics},\nnumber = {95},\ninstitution = {Univerzita Karlova},\naddress = {Praha, Czechia},\nissn = {0032-6585},\n}\n", "homepage": "http://ufal.ms.mff.cuni.cz/umc/005-en-ur/", "license": "", "features": {"id": {"dtype": "string", "id": null, "_type": "Value"}, "translation": {"languages": ["ur", "en"], "id": null, "_type": "Translation"}}, "post_processed": null, "supervised_keys": null, "builder_name": "u_m005", "config_name": "quran", "version": {"version_str": "1.0.0", "description": "", "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 2929711, "num_examples": 6000, "dataset_name": "u_m005"}, "validation": {"name": "validation", "num_bytes": 43499, "num_examples": 214, "dataset_name": "u_m005"}, "test": {"name": "test", "num_bytes": 44413, "num_examples": 200, "dataset_name": "u_m005"}}, "download_checksums": {"http://ufal.ms.mff.cuni.cz/umc/005-en-ur/download.php?f=umc005-corpus.zip": {"num_bytes": 3683565, "checksum": "6c09c759125c513ee16f06705475140e7738eae5c01c3d7a1198582e9f5a0998"}}, "download_size": 3683565, "post_processing_size": null, "dataset_size": 3017623, "size_in_bytes": 6701188}, "all": {"description": "UMC005 English-Urdu is a parallel corpus of texts in English and Urdu language with sentence alignments. The corpus can be used for experiments with statistical machine translation.\n\nThe texts come from four different sources:\n- Quran\n- Bible\n- Penn Treebank (Wall Street Journal)\n- Emille corpus\n\nThe authors provide the religious texts of Quran and Bible for direct download. Because of licensing reasons, Penn and Emille texts cannot be redistributed freely. However, if you already hold a license for the original corpora, we are able to provide scripts that will recreate our data on your disk. Our modifications include but are not limited to the following:\n\n- Correction of Urdu translations and manual sentence alignment of the Emille texts.\n- Manually corrected sentence alignment of the other corpora.\n- Our data split (training-development-test) so that our published experiments can be reproduced.\n- Tokenization (optional, but needed to reproduce our experiments).\n- Normalization (optional) of e.g. European vs. Urdu numerals, European vs. Urdu punctuation, removal of Urdu diacritics.\n", "citation": "@unpublished{JaZeWordOrderIssues2011,\nauthor = {Bushra Jawaid and Daniel Zeman},\ntitle = {Word-Order Issues in {English}-to-{Urdu} Statistical Machine Translation},\nyear = {2011},\njournal = {The Prague Bulletin of Mathematical Linguistics},\nnumber = {95},\ninstitution = {Univerzita Karlova},\naddress = {Praha, Czechia},\nissn = {0032-6585},\n}\n", "homepage": "http://ufal.ms.mff.cuni.cz/umc/005-en-ur/", "license": "", "features": {"id": {"dtype": "string", "id": null, "_type": "Value"}, "translation": {"languages": ["ur", "en"], "id": null, "_type": "Translation"}}, "post_processed": null, "supervised_keys": null, "builder_name": "u_m005", "config_name": "all", "version": {"version_str": "1.0.0", "description": "", "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 5280441, "num_examples": 13400, "dataset_name": "u_m005"}, "validation": {"name": "validation", "num_bytes": 156963, "num_examples": 514, "dataset_name": "u_m005"}, "test": {"name": "test", "num_bytes": 149079, "num_examples": 457, "dataset_name": "u_m005"}}, "download_checksums": {"http://ufal.ms.mff.cuni.cz/umc/005-en-ur/download.php?f=umc005-corpus.zip": {"num_bytes": 3683565, "checksum": "6c09c759125c513ee16f06705475140e7738eae5c01c3d7a1198582e9f5a0998"}}, "download_size": 3683565, "post_processing_size": null, "dataset_size": 5586483, "size_in_bytes": 9270048}}
|
dummy/all/1.0.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:48e3820ba8e00533f22f233804001106a4641536a495bc8809d3bfe3c8f706be
|
3 |
+
size 6473
|
dummy/bible/1.0.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:48e3820ba8e00533f22f233804001106a4641536a495bc8809d3bfe3c8f706be
|
3 |
+
size 6473
|
dummy/quran/1.0.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:48e3820ba8e00533f22f233804001106a4641536a495bc8809d3bfe3c8f706be
|
3 |
+
size 6473
|
um005.py
ADDED
@@ -0,0 +1,149 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2020 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 |
+
|
16 |
+
# Lint as: python3
|
17 |
+
import os
|
18 |
+
|
19 |
+
import datasets
|
20 |
+
|
21 |
+
|
22 |
+
_DESCRIPTION = """\
|
23 |
+
UMC005 English-Urdu is a parallel corpus of texts in English and Urdu language with sentence alignments. The corpus can be used for experiments with statistical machine translation.
|
24 |
+
|
25 |
+
The texts come from four different sources:
|
26 |
+
- Quran
|
27 |
+
- Bible
|
28 |
+
- Penn Treebank (Wall Street Journal)
|
29 |
+
- Emille corpus
|
30 |
+
|
31 |
+
The authors provide the religious texts of Quran and Bible for direct download. Because of licensing reasons, Penn and Emille texts cannot be redistributed freely. However, if you already hold a license for the original corpora, we are able to provide scripts that will recreate our data on your disk. Our modifications include but are not limited to the following:
|
32 |
+
|
33 |
+
- Correction of Urdu translations and manual sentence alignment of the Emille texts.
|
34 |
+
- Manually corrected sentence alignment of the other corpora.
|
35 |
+
- Our data split (training-development-test) so that our published experiments can be reproduced.
|
36 |
+
- Tokenization (optional, but needed to reproduce our experiments).
|
37 |
+
- Normalization (optional) of e.g. European vs. Urdu numerals, European vs. Urdu punctuation, removal of Urdu diacritics.
|
38 |
+
"""
|
39 |
+
_HOMEPAGE_URL = "http://ufal.ms.mff.cuni.cz/umc/005-en-ur/"
|
40 |
+
_URL = "http://ufal.ms.mff.cuni.cz/umc/005-en-ur/download.php?f=umc005-corpus.zip"
|
41 |
+
_CITATION = """\
|
42 |
+
@unpublished{JaZeWordOrderIssues2011,
|
43 |
+
author = {Bushra Jawaid and Daniel Zeman},
|
44 |
+
title = {Word-Order Issues in {English}-to-{Urdu} Statistical Machine Translation},
|
45 |
+
year = {2011},
|
46 |
+
journal = {The Prague Bulletin of Mathematical Linguistics},
|
47 |
+
number = {95},
|
48 |
+
institution = {Univerzita Karlova},
|
49 |
+
address = {Praha, Czechia},
|
50 |
+
issn = {0032-6585},
|
51 |
+
}
|
52 |
+
"""
|
53 |
+
|
54 |
+
_ALL = "all"
|
55 |
+
_VERSION = "1.0.0"
|
56 |
+
_SOURCES = ["bible", "quran"]
|
57 |
+
_SOURCES_FILEPATHS = {
|
58 |
+
s: {
|
59 |
+
"train": {"urdu": "train.ur", "english": "train.en"},
|
60 |
+
"dev": {"urdu": "dev.ur", "english": "dev.en"},
|
61 |
+
"test": {"urdu": "test.ur", "english": "test.en"},
|
62 |
+
}
|
63 |
+
for s in _SOURCES
|
64 |
+
}
|
65 |
+
|
66 |
+
|
67 |
+
class UM005Config(datasets.BuilderConfig):
|
68 |
+
def __init__(self, *args, sources=None, **kwargs):
|
69 |
+
super().__init__(*args, version=datasets.Version(_VERSION, ""), **kwargs)
|
70 |
+
self.sources = sources
|
71 |
+
|
72 |
+
@property
|
73 |
+
def language_pair(self):
|
74 |
+
return ("ur", "en")
|
75 |
+
|
76 |
+
|
77 |
+
class UM005(datasets.GeneratorBasedBuilder):
|
78 |
+
BUILDER_CONFIGS = [
|
79 |
+
UM005Config(name=source, sources=[source], description=f"Source: {source}.") for source in _SOURCES
|
80 |
+
] + [
|
81 |
+
UM005Config(
|
82 |
+
name=_ALL,
|
83 |
+
sources=_SOURCES,
|
84 |
+
description=f"All sources included: bible, quran",
|
85 |
+
)
|
86 |
+
]
|
87 |
+
BUILDER_CONFIG_CLASS = UM005Config
|
88 |
+
DEFAULT_CONFIG_NAME = _ALL
|
89 |
+
|
90 |
+
def _info(self):
|
91 |
+
return datasets.DatasetInfo(
|
92 |
+
description=_DESCRIPTION,
|
93 |
+
features=datasets.Features(
|
94 |
+
{
|
95 |
+
"id": datasets.Value("string"),
|
96 |
+
"translation": datasets.Translation(languages=self.config.language_pair),
|
97 |
+
},
|
98 |
+
),
|
99 |
+
supervised_keys=None,
|
100 |
+
homepage=_HOMEPAGE_URL,
|
101 |
+
citation=_CITATION,
|
102 |
+
)
|
103 |
+
|
104 |
+
def _split_generators(self, dl_manager):
|
105 |
+
path = dl_manager.download_and_extract(_URL)
|
106 |
+
return [
|
107 |
+
datasets.SplitGenerator(
|
108 |
+
name=datasets.Split.TRAIN,
|
109 |
+
gen_kwargs={"datapath": path, "datatype": "train"},
|
110 |
+
),
|
111 |
+
datasets.SplitGenerator(
|
112 |
+
name=datasets.Split.VALIDATION,
|
113 |
+
gen_kwargs={"datapath": path, "datatype": "dev"},
|
114 |
+
),
|
115 |
+
datasets.SplitGenerator(
|
116 |
+
name=datasets.Split.TEST,
|
117 |
+
gen_kwargs={"datapath": path, "datatype": "test"},
|
118 |
+
),
|
119 |
+
]
|
120 |
+
|
121 |
+
def _generate_examples(self, datapath, datatype):
|
122 |
+
if datatype == "train":
|
123 |
+
ur_file = "train.ur"
|
124 |
+
en_file = "train.en"
|
125 |
+
elif datatype == "dev":
|
126 |
+
ur_file = "dev.ur"
|
127 |
+
en_file = "dev.en"
|
128 |
+
elif datatype == "test":
|
129 |
+
ur_file = "test.ur"
|
130 |
+
en_file = "test.en"
|
131 |
+
else:
|
132 |
+
raise Exception("Invalid dataype. Try one of: dev, train, test")
|
133 |
+
|
134 |
+
for source in self.config.sources:
|
135 |
+
urdu_path = os.path.join(datapath, source, ur_file)
|
136 |
+
english_path = os.path.join(datapath, source, en_file)
|
137 |
+
with open(urdu_path, encoding="utf-8") as u, open(english_path, encoding="utf-8") as e:
|
138 |
+
for sentence_counter, (x, y) in enumerate(zip(u, e)):
|
139 |
+
x = x.strip()
|
140 |
+
y = y.strip()
|
141 |
+
result = (
|
142 |
+
sentence_counter,
|
143 |
+
{
|
144 |
+
"id": str(sentence_counter),
|
145 |
+
"translation": {"ur": x, "en": y},
|
146 |
+
},
|
147 |
+
)
|
148 |
+
sentence_counter += 1
|
149 |
+
yield result
|