Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions mindee/parsing/common/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,18 @@ def __str__(self) -> str:
def _inject_full_text_ocr(self, raw_prediction: StringDict) -> None:
pages = raw_prediction.get("inference", {}).get("pages", [])

# check for: empty, missing, or null
if (
not pages
or "extras" not in pages[0]
or "full_text_ocr" not in pages[0]["extras"]
or not pages[0].get("extras", None)
or not pages[0]["extras"].get("full_text_ocr", None)
):
return

full_text_content = "\n".join(
page["extras"]["full_text_ocr"]["content"]
for page in pages
if "extras" in page and "full_text_ocr" in page["extras"]
if page.get("extras", None) and page["extras"].get("full_text_ocr", None)
)

artificial_text_obj = {"content": full_text_content}
Expand Down