delete Khatt-Dataset-Unique-lines-full.py
Browse files
Khatt-Dataset-Unique-lines-full.py
DELETED
@@ -1,112 +0,0 @@
|
|
1 |
-
# coding=utf-8
|
2 |
-
# Copyright 2022 the 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 |
-
import datasets
|
17 |
-
|
18 |
-
|
19 |
-
_CITATION = """\
|
20 |
-
@article{Pattern Recognition,
|
21 |
-
Author = {bri A. Mahmoud, Irfan Ahmad, Wasfi G. Al-Khatib, Mohammad Alshayeb, Mohammad Tanvir Parvez, Volker Märgner, Gernot A. Fink},
|
22 |
-
Title = { {KHATT: An Open Arabic Offline Handwritten Text Database} },
|
23 |
-
Year = {2013},
|
24 |
-
doi = {10.1016/j.patcog.2013.08.009},
|
25 |
-
}
|
26 |
-
"""
|
27 |
-
|
28 |
-
_HOMEPAGE = "https://khatt.ideas2serve.net/KHATTAgreement.php"
|
29 |
-
|
30 |
-
_DESCRIPTION = """\
|
31 |
-
KHATT (KFUPM Handwritten Arabic TexT) database is a database of unconstrained handwritten Arabic Text written by 1000 different writers. This research database’s development was undertaken by a research group from KFUPM, Dhahran, S audi Arabia headed by Professor Sabri Mahmoud in collaboration with Professor Fink from TU-Dortmund, Germany and Dr. Märgner from TU-Braunschweig, Germany.
|
32 |
-
"""
|
33 |
-
|
34 |
-
_DATA_URL = {
|
35 |
-
"train_unique": [
|
36 |
-
"https://huggingface.co/datasets/Nada2125/Khatt_Dataset_full/resolve/main/data/train.zip"
|
37 |
-
],
|
38 |
-
"validation_unique": [
|
39 |
-
"https://huggingface.co/datasets/Nada2125/Khatt_Dataset_full/resolve/main/data/validation.zip"
|
40 |
-
],
|
41 |
-
"test_unique": [
|
42 |
-
"https://huggingface.co/datasets/Nada2125/Khatt_Dataset_full/resolve/main/data/validation.zip"
|
43 |
-
]
|
44 |
-
}
|
45 |
-
|
46 |
-
|
47 |
-
class KHATT(datasets.GeneratorBasedBuilder):
|
48 |
-
VERSION = datasets.Version("1.0.0")
|
49 |
-
|
50 |
-
def _info(self):
|
51 |
-
return datasets.DatasetInfo(
|
52 |
-
description=_DESCRIPTION,
|
53 |
-
features=datasets.Features(
|
54 |
-
{
|
55 |
-
"image": datasets.Image(),
|
56 |
-
"text": datasets.Value("string"),
|
57 |
-
}
|
58 |
-
),
|
59 |
-
homepage=_HOMEPAGE,
|
60 |
-
citation=_CITATION,
|
61 |
-
)
|
62 |
-
|
63 |
-
def _split_generators(self, dl_manager):
|
64 |
-
"""Returns SplitGenerators."""
|
65 |
-
archives = dl_manager.download(_DATA_URL)
|
66 |
-
|
67 |
-
return [
|
68 |
-
datasets.SplitGenerator(
|
69 |
-
name=datasets.Split.TRAIN,
|
70 |
-
gen_kwargs={
|
71 |
-
"archives": [dl_manager.iter_archive(archive) for archive in archives["train_unique"]],
|
72 |
-
"split": "train_unique",
|
73 |
-
},
|
74 |
-
),
|
75 |
-
datasets.SplitGenerator(
|
76 |
-
name=datasets.Split.VALIDATION,
|
77 |
-
gen_kwargs={
|
78 |
-
"archives": [dl_manager.iter_archive(archive) for archive in archives["validation_unique"]],
|
79 |
-
"split": "validation_unique",
|
80 |
-
},
|
81 |
-
),
|
82 |
-
datasets.SplitGenerator(
|
83 |
-
name=datasets.Split.TEST,
|
84 |
-
gen_kwargs={
|
85 |
-
"archives": [dl_manager.iter_archive(archive) for archive in archives["test_unique"]],
|
86 |
-
"split": "test_unique",
|
87 |
-
},
|
88 |
-
),
|
89 |
-
]
|
90 |
-
def _generate_examples(self, archives, split):
|
91 |
-
"""Yields examples."""
|
92 |
-
idx = 0
|
93 |
-
|
94 |
-
for archive in archives:
|
95 |
-
for path, file in archive:
|
96 |
-
# If we have an image
|
97 |
-
if path.endswith(".tif"):
|
98 |
-
if split != "test":
|
99 |
-
img_file = file
|
100 |
-
else:
|
101 |
-
text = ""
|
102 |
-
|
103 |
-
elif path.endswith(".txt"):
|
104 |
-
|
105 |
-
text = file.read()
|
106 |
-
text = text.decode('utf-8')
|
107 |
-
|
108 |
-
ex = {"image": {"path": path, "bytes": img_file.read()}, "text": text}
|
109 |
-
|
110 |
-
yield idx, ex
|
111 |
-
|
112 |
-
idx += 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|