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

Function build_manifest

scripts/extract_source_text.py:284–351  ·  view source on GitHub ↗
(
    *,
    record: dict[str, Any],
    pdf_path: Path,
    page_texts: list[dict[str, Any]],
    sections: list[dict[str, Any]],
    raw_sections_output: str,
    full_text_output: str,
    max_pages: int | None,
)

Source from the content-addressed store, hash-verified

282
283
284def build_manifest(
285 *,
286 record: dict[str, Any],
287 pdf_path: Path,
288 page_texts: list[dict[str, Any]],
289 sections: list[dict[str, Any]],
290 raw_sections_output: str,
291 full_text_output: str,
292 max_pages: int | None,
293) -> dict[str, Any]:
294 coverage = pdf_coverage_summary(pdf_path, max_pages=max_pages)
295 total_pages = coverage.get("total_pages")
296 extracted_pages = len(page_texts)
297 full_text = "\n".join(str(page.get("text", "")) for page in page_texts)
298 source_coverage = {
299 "total_pages": total_pages,
300 "text_max_pages": max_pages,
301 "text_pages_extracted": extracted_pages,
302 "text_pages_scanned": extracted_pages,
303 "text_truncated": bool(coverage.get("truncated_due_to_page_limit")),
304 "truncated_due_to_page_limit": bool(coverage.get("truncated_due_to_page_limit")),
305 "appendix_detected": bool(coverage.get("appendix_detected")),
306 "appendix_start_page": coverage.get("appendix_start_page"),
307 "references_start_page": coverage.get("references_start_page"),
308 }
309 return {
310 "status": "ok",
311 "script": "extract_source_text.py",
312 "schema_version": 1,
313 "paper_id": record.get("paper_id") or paper_id_for_record(record),
314 "title": record.get("title", ""),
315 "source_kind": "pdf_text",
316 "raw_sections_path": (
317 str(Path(raw_sections_output).expanduser().resolve()) if raw_sections_output else ""
318 ),
319 "full_text_md_path": (
320 str(Path(full_text_output).expanduser().resolve()) if full_text_output else ""
321 ),
322 "pdf": {
323 "path": str(pdf_path),
324 "total_pages": total_pages,
325 "text_pages_extracted": extracted_pages,
326 "text_max_pages": max_pages,
327 "text_truncated": bool(coverage.get("truncated_due_to_page_limit")),
328 },
329 "coverage": source_coverage,
330 "sections": [
331 {
332 key: section.get(key)
333 for key in (
334 "section_id",
335 "kind",
336 "title",
337 "page_start",
338 "page_end",
339 "char_count",
340 "text_hash_sha256",
341 )

Callers 1

mainFunction · 0.85

Calls 8

pdf_coverage_summaryFunction · 0.90
paper_id_for_recordFunction · 0.90
extract_appendix_indexFunction · 0.90
build_pagesFunction · 0.85
caption_manifestFunction · 0.85
math_indexFunction · 0.85
text_hashFunction · 0.85
language_hint_for_textFunction · 0.70

Tested by

no test coverage detected