Pipeline Architecture
Legislative amendments are diffs. We treat the Gazette like a version control system — each amendment is a patch applied to the base law.
PDF → Markdown
Gazette PDFs (bilingual Hindi/English) are fed through Mistral OCR to produce clean, structured Markdown preserving section numbering, clause hierarchy, and table formatting.
Normalize & Structure
The raw OCR output is cleaned — fixing encoding artefacts, normalizing whitespace, ensuring consistent heading levels and clause numbering so downstream string matching works reliably.
Amendment → Edit Operations
The amendment notification is natural-language diffing: "in Rule 3, for the words 'fifteen days' the words 'seventy-two hours' shall be substituted." The LLM parses each directive into structured edit operations.
Execute String Replacements
Each edit operation is applied sequentially to the current consolidated text using exact string matching — the same oldString → newString mechanism a code editor uses. No LLM involved in the application step; it's deterministic.
Diff Against Known-Good
The generated consolidated version is diffed against independently sourced known-good copies (e.g., from Trilegal's manual consolidation). Any discrepancies surface errors in either the OCR, the amendment parsing, or the source material itself.
Display As Amended
The consolidated Markdown is rendered with full legal formatting — section hierarchy, clause indentation, tables — along with amendment diffs highlighted inline showing exactly what changed and when.