Extract all key entities required by SAP from Protocol PDF/DOCX and output structured JSON.
Quick Start
from utils.document_parser import get_document_parser
parser = get_document_parser()
synopsis = await parser.parse(protocol_path, page_range=[1, 15])
stats = await parser.parse(protocol_path, page_range=[90, 115])
Parsing Strategy
Multi-section targeted parsing: Synopsis(p1-15, high table density) -> Design(p30-50) -> Statistics(p90-115, plain text) -> SAP Appendix(p240+)
Parsing Engine (four-level fallback)
DocumentParser automatically selects the optimal engine:
- Unstructured API (cloud) — requires UNSTRUCTURED_API_KEY, strongest for tables + OCR
- Docling (local AI) — IBM open source, uses vision + language models for table recognition, no API Key required, recommended local first choice
- pdfplumber (local) — text + simple tables
- PyPDF2 (local) — plain text fallback only
If UNSTRUCTURED_API_KEY is not configured and Docling is installed, Docling will be used automatically (table recognition accuracy is far higher than pdfplumber).
References
- prompts/ — 6 dedicated extraction Prompts
- scripts/parse_protocol.py — multi-section parsing orchestration
- scripts/merge_entities.py — entity merging and cross-validation
- schemas/protocol_entities.json — output JSON Schema
- reference/section_mapping.md — section classification rules