perf(kb):1.优化 PDF只对可疑页做 image box 分析避免整本重复扫描/重复 reopen;2.doc/.docx 不再因为“有图片”就强制 OCR;3.只在 intake 路由 明确要求 OCR 时才跑
This commit is contained in:
1 parent
a3123cd602
commit
c58ed37cc1
11 files changed
+717
-122
No files matched your search
@@ -206,7 +206,17 @@ def blocks_to_plain_markdown(blocks: list[Block]) -> str:
|
||||
lines.append(f"## {txt}")
|
||||
elif b.type == "image":
|
||||
data_uri = b.meta.get("data_uri") if b.meta else None
|
||||
if data_uri:
|
||||
is_pdf_page_image = bool(
|
||||
b.meta
|
||||
and b.meta.get("page_image")
|
||||
and b.meta.get("page_image_source") == "pdf"
|
||||
)
|
||||
if is_pdf_page_image:
|
||||
lines.append(f"![page-image-{b.page}]")
|
||||
ocr_text = ocr_by_image.get(b.id)
|
||||
if ocr_text:
|
||||
lines.append(f"图中文字:{ocr_text}")
|
||||
elif data_uri:
|
||||
image_idx += 1
|
||||
if b.meta and b.meta.get("page_image"):
|
||||
lines.append(f"")
|
||||
@@ -220,11 +230,7 @@ def blocks_to_plain_markdown(blocks: list[Block]) -> str:
|
||||
page_body_chars.get(b.page, 0) >= 15
|
||||
or page_text_chars.get(b.page, 0) >= 40
|
||||
)
|
||||
if (
|
||||
b.meta
|
||||
and b.meta.get("page_image")
|
||||
and b.meta.get("page_image_source") != "pptx"
|
||||
):
|
||||
if b.meta and b.meta.get("page_image"):
|
||||
lines.extend(_page_image_structured_lines(ocr_text))
|
||||
if not suppress_pptx_ocr:
|
||||
lines.append(f"图中文字:{ocr_text}")
|
||||
|
||||
Reference in new issue
Block a user