dllmforge.IE_agent_provenance¶
Quote-first provenance: recover source_page from source_quote against a Docling index.
The LLM copies a verbatim quote. Page numbers are assigned in code by locating that quote in page-indexed elements (sections, tables, figures, prose).
Functions
|
Walk a parsed extraction dict and fill source_page from source_quote. |
|
Return the best matching index element for a quote, or None. |
|
Accept element_index ({page, type, text}) or page_index ({page, text}). |
|
Collapse whitespace, fix OCR units (50m -> 50 m), lowercase. |
|
Copy processor metadata without the bulky locator index. |
- dllmforge.IE_agent_provenance.public_metadata(meta: Dict[str, Any] | None) Dict[str, Any][source]¶
Copy processor metadata without the bulky locator index.
- dllmforge.IE_agent_provenance.normalize_text(value: str) str[source]¶
Collapse whitespace, fix OCR units (50m -> 50 m), lowercase.
- dllmforge.IE_agent_provenance.normalize_index(index: Iterable[Dict[str, Any]] | None) List[Dict[str, Any]][source]¶
Accept element_index ({page, type, text}) or page_index ({page, text}).
- dllmforge.IE_agent_provenance.locate_quote(quote: str, index: Iterable[Dict[str, Any]] | None, fuzzy_threshold: float = 0.55) Dict[str, Any] | None[source]¶
Return the best matching index element for a quote, or None.
Long LLM quotes often concatenate a sentence + a table + more prose. Match the whole string first, then each paragraph, and prefer a table hit when the quote contains a markdown table.
- dllmforge.IE_agent_provenance.apply_quote_provenance(obj: Any, index: Iterable[Dict[str, Any]] | None = None, metadata: Dict[str, Any] | None = None) Any[source]¶
Walk a parsed extraction dict and fill source_page from source_quote.
If
indexis omitted,metadata['element_index']ormetadata['page_index']is used. Unmatched quotes getquote_verified=Falseandsource_page=None(do not keep a guessed page).