File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change 38
38
from textractor .entities .layout import Layout
39
39
from textractor .data .constants import (
40
40
LAYOUT_ENTITY ,
41
+ LAYOUT_FIGURE ,
41
42
TABLE_FOOTER ,
42
43
TABLE_TITLE ,
43
44
COLUMN_HEADER ,
@@ -1282,7 +1283,7 @@ def parse_document_api_response(response: dict) -> Document:
1282
1283
key_values .remove (kv )
1283
1284
1284
1285
1285
- page .leaf_layouts = [l for l in page .leaf_layouts if l .children ]
1286
+ page .leaf_layouts = [l for l in page .leaf_layouts if l .children or l . layout_type == LAYOUT_FIGURE ]
1286
1287
1287
1288
# We create layout elements for the KeyValues that did not match to a layout element in the
1288
1289
# previous step
@@ -1334,7 +1335,7 @@ def parse_document_api_response(response: dict) -> Document:
1334
1335
words_in_sub_layouts .add (w )
1335
1336
for word in words_in_sub_layouts :
1336
1337
layout .remove (word )
1337
- if not layout .children :
1338
+ if not layout .children and layout . layout_type != LAYOUT_FIGURE :
1338
1339
layouts_to_remove .append (layout )
1339
1340
1340
1341
# Clean up layouts that became empty due to the previous step.
@@ -1380,7 +1381,7 @@ def parse_document_api_response(response: dict) -> Document:
1380
1381
word_set = set ()
1381
1382
for layout in sorted (page .layouts , key = lambda l : l .reading_order ):
1382
1383
layout .visit (word_set )
1383
- if not layout .children :
1384
+ if not layout .children and layout . layout_type != LAYOUT_FIGURE :
1384
1385
try :
1385
1386
page .leaf_layouts .remove (layout )
1386
1387
except :
You can’t perform that action at this time.
0 commit comments