Datasets:
Youssef Benhachem
commited on
Commit
·
5038e3d
1
Parent(s):
2bf1109
Builder script
Browse files
KHATT.py
CHANGED
@@ -39,19 +39,17 @@ ILSVRC 2012, commonly known as 'ImageNet' is an image dataset organized accordin
|
|
39 |
|
40 |
_DATA_URL = {
|
41 |
"train": [
|
42 |
-
"https://huggingface.co/datasets/benhachem/KHATT/resolve/main/data/
|
43 |
],
|
44 |
"val": [
|
45 |
"https://huggingface.co/datasets/benhachem/KHATT/resolve/main/data/Validation.zip"
|
46 |
],
|
47 |
-
|
48 |
-
"https://huggingface.co/datasets/benhachem/KHATT/resolve/main/data/Test.zip"
|
49 |
-
],
|
50 |
}
|
51 |
|
52 |
|
53 |
class KHATT(datasets.GeneratorBasedBuilder):
|
54 |
-
VERSION = datasets.Version("1.0
|
55 |
|
56 |
def _info(self):
|
57 |
return datasets.DatasetInfo(
|
@@ -85,33 +83,24 @@ class KHATT(datasets.GeneratorBasedBuilder):
|
|
85 |
"split": "validation",
|
86 |
},
|
87 |
),
|
88 |
-
datasets.SplitGenerator(
|
89 |
-
name=datasets.Split.TEST,
|
90 |
-
gen_kwargs={
|
91 |
-
"archives": [dl_manager.iter_archive(archive) for archive in archives["test"]],
|
92 |
-
"split": "test",
|
93 |
-
},
|
94 |
-
),
|
95 |
]
|
96 |
|
97 |
def _generate_examples(self, archives, split):
|
98 |
"""Yields examples."""
|
99 |
-
from datasets.utils.download_manager import DownloadManager
|
100 |
-
|
101 |
-
dl_manager = DownloadManager()
|
102 |
idx = 0
|
103 |
-
|
104 |
-
texts = pd.read_excel(path_labels)
|
105 |
-
|
106 |
-
for archive in archives[:-1]:
|
107 |
for path, file in archive:
|
108 |
if path.endswith(".TIF"):
|
109 |
if split != "test":
|
110 |
# image filepath format: <FormNo>_<ParagraphNo>_<LineNo>.TIF
|
111 |
root, _ = os.path.splitext(path)
|
112 |
-
|
113 |
-
|
114 |
-
|
|
|
|
|
|
|
|
|
115 |
else:
|
116 |
text = ""
|
117 |
|
|
|
39 |
|
40 |
_DATA_URL = {
|
41 |
"train": [
|
42 |
+
"https://huggingface.co/datasets/benhachem/KHATT/resolve/main/data/Training.zip"
|
43 |
],
|
44 |
"val": [
|
45 |
"https://huggingface.co/datasets/benhachem/KHATT/resolve/main/data/Validation.zip"
|
46 |
],
|
47 |
+
|
|
|
|
|
48 |
}
|
49 |
|
50 |
|
51 |
class KHATT(datasets.GeneratorBasedBuilder):
|
52 |
+
VERSION = datasets.Version("1.0")
|
53 |
|
54 |
def _info(self):
|
55 |
return datasets.DatasetInfo(
|
|
|
83 |
"split": "validation",
|
84 |
},
|
85 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
]
|
87 |
|
88 |
def _generate_examples(self, archives, split):
|
89 |
"""Yields examples."""
|
|
|
|
|
|
|
90 |
idx = 0
|
91 |
+
for archive in archives:
|
|
|
|
|
|
|
92 |
for path, file in archive:
|
93 |
if path.endswith(".TIF"):
|
94 |
if split != "test":
|
95 |
# image filepath format: <FormNo>_<ParagraphNo>_<LineNo>.TIF
|
96 |
root, _ = os.path.splitext(path)
|
97 |
+
txt_path = root + ".txt"
|
98 |
+
|
99 |
+
# txt_path = path[:-4] + ".txt"
|
100 |
+
|
101 |
+
with open(txt_path, 'r', encoding='utf-8'):
|
102 |
+
text = txt_path.read()
|
103 |
+
|
104 |
else:
|
105 |
text = ""
|
106 |
|