| 34 | |
| 35 | |
| 36 | def parser() -> argparse.ArgumentParser: |
| 37 | p = argparse.ArgumentParser(description=__doc__ or "extract source text") |
| 38 | p.add_argument( |
| 39 | "--input", |
| 40 | required=True, |
| 41 | help="Fetch JSON path, metadata JSON path, local PDF path, JSON string, or reference.", |
| 42 | ) |
| 43 | p.add_argument("--output", default="", help="Source manifest JSON output path.") |
| 44 | p.add_argument( |
| 45 | "--raw-sections-output", |
| 46 | default="", |
| 47 | help="Canonical raw sections JSONL output path.", |
| 48 | ) |
| 49 | p.add_argument("--full-text-output", default="", help="Optional derived Markdown output path.") |
| 50 | p.add_argument("--paper-id", default="", help="Canonical paper id if already known.") |
| 51 | p.add_argument( |
| 52 | "--max-pages", |
| 53 | type=int, |
| 54 | default=None, |
| 55 | help="Optional page limit. Omit for all pages.", |
| 56 | ) |
| 57 | return p |
| 58 | |
| 59 | |
| 60 | def ensure_record(input_value: str) -> dict[str, Any]: |