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

Function main

scripts/extract_source_text.py:354–386  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

352
353
354def main() -> None:
355 args = parser().parse_args()
356 record = ensure_record(args.input)
357 record["paper_id"] = args.paper_id or record.get("paper_id") or paper_id_for_record(record)
358 pdf_path = resolve_pdf_path(record)
359 if pdf_path is None:
360 raise SystemExit("extract_source_text.py requires a resolvable local PDF path.")
361
362 raw_sections_output = args.raw_sections_output
363 if not raw_sections_output and args.output:
364 raw_sections_output = str(
365 Path(args.output).with_name(
366 Path(args.output).stem.replace("_source_manifest", "") + "_raw_sections.jsonl"
367 )
368 )
369
370 page_texts = extract_page_texts(pdf_path, args.max_pages)
371 sections = extract_raw_sections(page_texts)
372 if raw_sections_output:
373 write_jsonl(sections, raw_sections_output)
374 if args.full_text_output:
375 write_full_text_markdown(sections, args.full_text_output, str(record.get("title", "")))
376
377 manifest = build_manifest(
378 record=record,
379 pdf_path=pdf_path,
380 page_texts=page_texts,
381 sections=sections,
382 raw_sections_output=raw_sections_output,
383 full_text_output=args.full_text_output,
384 max_pages=args.max_pages,
385 )
386 emit(manifest, args.output)
387
388
389if __name__ == "__main__":

Callers 1

Calls 10

paper_id_for_recordFunction · 0.90
emitFunction · 0.90
resolve_pdf_pathFunction · 0.85
extract_page_textsFunction · 0.85
extract_raw_sectionsFunction · 0.85
write_jsonlFunction · 0.85
write_full_text_markdownFunction · 0.85
build_manifestFunction · 0.85
parserFunction · 0.70
ensure_recordFunction · 0.70

Tested by

no test coverage detected