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
14 changes: 14 additions & 0 deletions docling/models/base_ocr_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,20 @@ def post_process_cells(self, ocr_cells: List[TextCell], page: Page) -> None:
page.parsed_page.textline_cells = final_cells
page.parsed_page.has_lines = len(final_cells) > 0

# When force_full_page_ocr is used, PDF-extracted word/char cells are
# unreliable. Filter out cells where from_ocr=False, keeping any OCR-
# generated cells. This ensures downstream components (e.g., table
# structure model) fall back to OCR-extracted textline cells.
if self.options.force_full_page_ocr:
page.parsed_page.word_cells = [
c for c in page.parsed_page.word_cells if c.from_ocr
]
page.parsed_page.char_cells = [
c for c in page.parsed_page.char_cells if c.from_ocr
]
page.parsed_page.has_words = len(page.parsed_page.word_cells) > 0
page.parsed_page.has_chars = len(page.parsed_page.char_cells) > 0

def _combine_cells(
self, existing_cells: List[TextCell], ocr_cells: List[TextCell]
) -> List[TextCell]:
Expand Down