close to done for bboxes
Browse files- DUDE_loader.py +16 -12
DUDE_loader.py
CHANGED
@@ -103,17 +103,15 @@ class DUDE(datasets.GeneratorBasedBuilder):
|
|
103 |
"questionId": datasets.Value("string"),
|
104 |
"question": datasets.Value("string"),
|
105 |
"answers": datasets.Sequence(datasets.Value("string")),
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
# ),
|
116 |
-
# '''
|
117 |
"answers_variants": datasets.Sequence(datasets.Value("string")),
|
118 |
"answer_type": datasets.Value("string"),
|
119 |
"data_split": datasets.Value("string"),
|
@@ -186,6 +184,12 @@ class DUDE(datasets.GeneratorBasedBuilder):
|
|
186 |
a["data_split"] = split
|
187 |
a["document"] = retrieve_doc(pdfs_archive, a["docId"])
|
188 |
a["OCR"] = retrieve_OCR(OCR_archive, a["docId"])
|
189 |
-
a.pop("answers_page_bounding_boxes") # fix later
|
190 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
191 |
yield i, a
|
|
|
103 |
"questionId": datasets.Value("string"),
|
104 |
"question": datasets.Value("string"),
|
105 |
"answers": datasets.Sequence(datasets.Value("string")),
|
106 |
+
"answers_page_bounding_boxes": datasets.Sequence(
|
107 |
+
{
|
108 |
+
"left": datasets.Value("int32"),
|
109 |
+
"top": datasets.Value("int32"),
|
110 |
+
"width": datasets.Value("int32"),
|
111 |
+
"height": datasets.Value("int32"),
|
112 |
+
"page": datasets.Value("int32"),
|
113 |
+
}
|
114 |
+
),
|
|
|
|
|
115 |
"answers_variants": datasets.Sequence(datasets.Value("string")),
|
116 |
"answer_type": datasets.Value("string"),
|
117 |
"data_split": datasets.Value("string"),
|
|
|
184 |
a["data_split"] = split
|
185 |
a["document"] = retrieve_doc(pdfs_archive, a["docId"])
|
186 |
a["OCR"] = retrieve_OCR(OCR_archive, a["docId"])
|
|
|
187 |
|
188 |
+
# FIXES for faulty generation
|
189 |
+
#a.pop("answers_page_bounding_boxes") # fix later
|
190 |
+
if a["answers_page_bounding_boxes"] in [ [], [[]] ]:
|
191 |
+
a["answers_page_bounding_boxes"] = None
|
192 |
+
else:
|
193 |
+
if isinstance(a['answers_page_bounding_boxes'][0], list):
|
194 |
+
a["answers_page_bounding_boxes"] = a['answers_page_bounding_boxes'][0]
|
195 |
yield i, a
|