| 82 | return segments |
| 83 | |
| 84 | def _process_page_cells(page: Page): |
| 85 | cells: List[dict] = [] |
| 86 | if page.size is None: |
| 87 | return cells |
| 88 | for cell in page.cells: |
| 89 | new_bbox = cell.bbox.to_top_left_origin( |
| 90 | page_height=page.size.height |
| 91 | ).normalized(page_size=page.size) |
| 92 | is_ocr = isinstance(cell, OcrCell) |
| 93 | ocr_confidence = cell.confidence if isinstance(cell, OcrCell) else 1.0 |
| 94 | cells.append( |
| 95 | { |
| 96 | "text": cell.text, |
| 97 | "bbox": new_bbox.as_tuple(), |
| 98 | "ocr": is_ocr, |
| 99 | "ocr_confidence": ocr_confidence, |
| 100 | } |
| 101 | ) |
| 102 | return cells |
| 103 | |
| 104 | def _process_page(): |
| 105 | page_ix = page_no - 1 |