Skip to content

Commit fbeb7b0

Browse files
authored
Add function to split larger element at table insertion
2 parents 28af95b + e339a5c commit fbeb7b0

File tree

2 files changed

+179
-101
lines changed

2 files changed

+179
-101
lines changed

textractor/entities/page.py

Lines changed: 9 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ def __init__(
7373
self._tables: EntityList[Table] = EntityList([])
7474
self._queries: EntityList[Query] = EntityList([])
7575
self._expense_documents: EntityList[ExpenseDocument] = EntityList([])
76-
self._leaf_layouts: EntityList[Layout] = EntityList([])
77-
self._container_layouts: EntityList[Layout] = EntityList([])
76+
self._layouts: EntityList[Layout] = EntityList([])
7877
self.kv_cache = defaultdict(list)
7978
self.metadata = {}
8079
self.page_num = page_num
@@ -315,52 +314,27 @@ def layouts(self) -> EntityList[Layout]:
315314
:return: List of Layout objects.
316315
:rtype: EntityList
317316
"""
318-
return EntityList(
319-
sorted(
320-
self._leaf_layouts + self._container_layouts,
321-
key=lambda c: c.reading_order,
322-
)
323-
)
317+
return EntityList(sorted(self._layouts, key=lambda c: c.reading_order,))
324318

325319
@property
326-
def leaf_layouts(self) -> EntityList[Layout]:
327-
"""
328-
Returns all the leaf :class:`Layout` objects present in the Page.
329-
330-
:return: List of Layout objects.
331-
:rtype: EntityList
332-
"""
333-
return self._leaf_layouts
334-
335-
@leaf_layouts.setter
336-
def leaf_layouts(self, leaf_layouts: List[Layout]):
337-
"""
338-
Add leaf layout objects to the Page.
339-
340-
:param layouts: List of Layout objects.
341-
:type layouts: list
342-
"""
343-
self._leaf_layouts = EntityList(leaf_layouts)
344-
345-
@property
346-
def container_layouts(self) -> EntityList[Layout]:
320+
def layouts(self) -> EntityList[Layout]:
347321
"""
348-
Returns all the container :class:`Layout` objects present in the Page.
322+
Returns all the :class:`Layout` objects present in the Page.
349323
350324
:return: List of Layout objects.
351325
:rtype: EntityList
352326
"""
353-
return self._container_layouts
327+
return self._layouts
354328

355-
@container_layouts.setter
356-
def container_layouts(self, container_layouts: List[Layout]):
329+
@layouts.setter
330+
def layouts(self, layouts: List[Layout]):
357331
"""
358-
Add Layout objects to the Page.
332+
Add layout objects to the Page.
359333
360334
:param layouts: List of Layout objects.
361335
:type layouts: list
362336
"""
363-
self._container_layouts = EntityList(container_layouts)
337+
self._layouts = EntityList(layouts)
364338

365339
@property
366340
def expense_documents(self) -> EntityList[ExpenseDocument]:

0 commit comments

Comments
 (0)