27 lines
1.0 KiB
Python
27 lines
1.0 KiB
Python
from insurance.ppt.extraction import (
|
|
_extract_document_text,
|
|
_page_policy_years,
|
|
_select_page_chunks,
|
|
_select_primary_benefit_pages,
|
|
_split_marked_pages,
|
|
)
|
|
|
|
keywords = (
|
|
"保单年度", "保單年度", "退保价值", "退保價值", "保证现金", "保證現金",
|
|
"保单年", "保單年", "户口价值", "戶口價值", "保证基础", "保證基礎",
|
|
"policy year", "cash value", "surrender value", "account value",
|
|
)
|
|
|
|
for path in (
|
|
"/app/api/storage/insurance/test_e2e/manulife.pdf",
|
|
"/app/api/storage/insurance/test_e2e/transamerica.pdf",
|
|
):
|
|
text, *_ = _extract_document_text(path)
|
|
selected = _select_primary_benefit_pages(text, keywords)
|
|
pages = [
|
|
(number, min(_page_policy_years(content) or {0}), max(_page_policy_years(content) or {0}))
|
|
for number, content in _split_marked_pages(selected)
|
|
]
|
|
chunks = _select_page_chunks(selected, keywords, min_keyword_hits=2, pages_per_chunk=2)
|
|
print(path, "pages=", pages, "chunks=", len(chunks))
|