AS AMENDED|Pipeline
Back to Demo

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.

1
Extract

PDF → Markdown

Mistral OCR

Gazette PDFs (bilingual Hindi/English) are fed through Mistral OCR to produce clean, structured Markdown preserving section numbering, clause hierarchy, and table formatting.

INIT Rules 2021.pdf
→
OUTbase-2021.md
2
Clean

Normalize & Structure

Claude

The raw OCR output is cleaned — fixing encoding artefacts, normalizing whitespace, ensuring consistent heading levels and clause numbering so downstream string matching works reliably.

INbase-2021.md (raw)
→
OUTbase-2021.md (clean)
per amendment
3
Parse

Amendment → Edit Operations

Claude

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.

INamendment-2022.pdf
→
OUT[ { oldString: "fifteen days", newString: "seventy-two hours", location: "Rule 3(2)(a)" }, { oldString: "...", newString: "...", location: "Rule 4(1)" }, ... ]
4
Apply

Execute String Replacements

Edit Tool

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.

INbase-2021.md + edit ops
→
OUTconsolidated-2022.md
5
Verify

Diff Against Known-Good

Diff

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.

INconsolidated-2022.md vs known-good-2022.md
→
OUT0 discrepancies ✓
6
Render

Display As Amended

Streamdown

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.

INconsolidated-2025.md
→
OUTInteractive UI

The Git Analogy

Base Act
Initial commit — the original file
Amendment notification
A commit / patch with diffs
Consolidated as-amended
Current file state after all patches
Version as of a date
Checking out a specific commit