handwritten margin strike-through read as characters - OCR injected junk into the operative clause and the agent...
Fixes OCR injecting handwriting junk into contract text: a margin strike-through got read as characters and the agent quoted the garbage as operative clause language. It shows how to separate handwriting from print, mask margin annotations before OCR, and strip junk tokens from quoted clauses. Use it when scanned contracts carry handwritten marks and your agent quotes text nobody should rely on.
TL;DR A handwritten margin strike-through got OCR'd as characters, injected into the operative clause, and the agent quoted the junk verbatim. Separate the handwriting layer from the print layer before OCR, mask or inpaint the margin marks, and never quote clause text that contains tokens no dictionary or classifier recognizes. Junk in means flagged for review, not quoted as fact.
What the OCR output looked like:
the Licensee shall pay the Fee ... [unreadable stroke characters] ... within thirty daysSteps
- Find the damage. Search your OCR output for the quoted clause and look for character runs that do not form words.
Command: grep -rn "Licensee shall" ocr_text/ | head Expected: the clause line contains a run of nonsense characters where the margin strike-through bled into the text column.
- Add a handwriting separation pass before OCR. Run the page through a print-versus-handwriting segmentation step and OCR the print layer alone, keeping the handwriting layer as a separate annotation.
Expected: the operative clause OCRs cleanly with no injected characters, and the margin mark is stored as an annotation, not body text.
- If you do not have a segmentation model, mask the margin regions. Detect dark stroke regions in the margins and inpaint them before OCR, or simply exclude a margin band from the text column.
Expected: re-OCR of the page produces the clause without the junk characters.
- Add a junk-token guard on quoted clauses. Before the agent quotes any clause, check that every token is a real word or a known legal term; if junk tokens remain, flag the quote for review instead of emitting it.
Expected: any remaining OCR junk triggers a review flag, never a verbatim quote presented as operative language.
Use this when
- Scanned contracts have handwritten strike-throughs, margin notes, or initials
- OCR output contains runs of nonsense characters inside otherwise clean clauses
- Your agent quotes clause text that includes obvious garbage
- Signature pages or initialed pages bleed marks into nearby text
Not for this skill when
- The handwriting is the operative content, like a handwritten amendment, which needs its own transcription pass, not masking
- The junk comes from a stain or fax artifact rather than handwriting, use image cleanup instead
- The document is born-digital, there is no handwriting layer to separate
- The quote is clean but the agent misattributes which clause it came from, that is a citation problem
Variant phrasings
- handwritten strike-through read as characters by OCR
- OCR injected junk into the contract clause text
- agent quoted garbage characters as operative language
- how to separate handwriting from print before OCR
- margin annotations polluting contract OCR output
Why it happens
OCR engines do not know the difference between printed contract text and a handwritten mark crossing it; they transcribe every dark pixel cluster they find. A strike-through drawn across a clause becomes a string of stroke fragments that the engine renders as characters, and those characters land inline in the clause text. The agent then has no reason to doubt them, so it quotes the corrupted clause verbatim. The root problem is treating the page as one text layer when it has two: the printed agreement and the human marks on top of it.
Edge cases
- A handwritten strike-through can be legally operative, like a negotiated deletion, so keep the annotation layer and surface it to the reviewer, do not just delete it silently.
- Initials in the margin are common and harmless; your segmentation should classify mark types, not nuke all handwriting.
- Inpainting can smear nearby print if the mask is too aggressive, keep the mask tight to the detected strokes and re-check the surrounding words.
- Cursive handwriting near printed text confuses some segmentation models, fall back to the margin-band exclusion in step 3 for those pages.
- If the clause is quoted from a page you already cleaned, keep the before and after images so a reviewer can verify the strike-through did not remove real text.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_9RMQVlRKAw3R-LI3k69OrQ
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.