Skip to content

Commit 6be913d

Browse files
Fix STATIC_PARSE for images #156 (#157)
* Fix STATIC_PARSE for images #156 * Address review comments #156, #157 * Revert filename for test_cost_priority_routing #156, #157
1 parent eb513e4 commit 6be913d

4 files changed

Lines changed: 810 additions & 667 deletions

File tree

182 KB
Binary file not shown.

lexoid/core/parse_type/static_parser.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -770,8 +770,10 @@ def parse_with_paddleocr(path: str, **kwargs) -> Dict:
770770
for result in results:
771771
page_texts = []
772772
page_bboxes = []
773+
# OCRResult as dict
774+
page_num = dict(result).get("page_index", 0) # return value could be None
775+
page_num = page_num or 0
773776

774-
page_num = result["page_index"]
775777
height_img, width_img, _ = result["doc_preprocessor_res"]["output_img"].shape
776778
for text, bbox in zip(result["rec_texts"], result["dt_polys"]):
777779
x_coords = bbox[:, 0]
@@ -794,7 +796,6 @@ def parse_with_paddleocr(path: str, **kwargs) -> Dict:
794796

795797
page_text_str = " ".join(page_texts)
796798
all_texts.append(page_text_str)
797-
798799
segments.append(
799800
{
800801
"metadata": {"page": kwargs.get("start", 1) + page_num},

0 commit comments

Comments
 (0)