MCPcopy Create free account
hub / github.com/917Dhj/DeepPaperNote / extract_appendix_page_texts

Function extract_appendix_page_texts

scripts/common.py:1810–1832  ·  view source on GitHub ↗
(
    pdf_path: Path,
    appendix_start_page: int | None,
)

Source from the content-addressed store, hash-verified

1808
1809
1810def extract_appendix_page_texts(
1811 pdf_path: Path,
1812 appendix_start_page: int | None,
1813) -> list[dict[str, Any]]:
1814 if fitz is None or not pdf_path.is_file() or not appendix_start_page:
1815 return []
1816
1817 try:
1818 doc = fitz.open(pdf_path)
1819 except Exception:
1820 return []
1821
1822 pages: list[dict[str, Any]] = []
1823 try:
1824 start_index = max(int(appendix_start_page) - 1, 0)
1825 for page_index in range(start_index, len(doc)):
1826 text = doc[page_index].get_text("text")
1827 cleaned = normalize_whitespace(text)
1828 if cleaned:
1829 pages.append({"page": page_index + 1, "text": text})
1830 finally:
1831 doc.close()
1832 return pages
1833
1834
1835def appendix_section_title(line: str) -> str:

Callers 2

mainFunction · 0.90
extract_appendix_indexFunction · 0.85

Calls 4

normalize_whitespaceFunction · 0.85
openMethod · 0.45
get_textMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected