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

Function extract_page_texts

scripts/extract_source_text.py:134–145  ·  view source on GitHub ↗
(pdf_path: Path, max_pages: int | None)

Source from the content-addressed store, hash-verified

132
133
134def extract_page_texts(pdf_path: Path, max_pages: int | None) -> list[dict[str, Any]]:
135 if fitz is None:
136 raise RuntimeError("PyMuPDF is required for source text extraction.")
137 doc = fitz.open(pdf_path)
138 try:
139 page_limit = len(doc) if max_pages is None else min(len(doc), max_pages)
140 return [
141 {"page": page_index + 1, "text": doc[page_index].get_text("text")}
142 for page_index in range(page_limit)
143 ]
144 finally:
145 doc.close()
146
147
148def extract_raw_sections(page_texts: list[dict[str, Any]]) -> list[dict[str, Any]]:

Callers 1

mainFunction · 0.85

Calls 3

openMethod · 0.45
get_textMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected