feat(parser): reorder scrambled lines by bounding box #99

Closed
opened 2026-07-07 09:26:35 +01:00 by TimCane · 0 comments
TimCane commented 2026-07-07 09:26:35 +01:00 (Migrated from github.com)

Parent: #77 (Phase B, capability - last, riskiest). Invariants live in the epic.

Reorder scrambled lines using bounding boxes before parsing.

Anchors

  • OcrBox (OcrResult.cs:11) - the X/Y/Width/Height to sort on.
  • Current code trusts line order except for the total's Box.Y
    (ReceiptParser.cs:112,128).
  • Seed fixture: backend/tests/BillSplitter.Tests/Fixtures/receipts/westminster-column-drift.

Steps

  1. Add a pre-pass sorting lines by Box.Y then Box.X with a row tolerance.
  2. Tolerance-gate it: only reorder when boxes prove drift; leave already-ordered
    receipts alone.

Done

  • New drift fixture(s) demonstrating recovery.
  • Existing corpus green.
Parent: #77 (Phase B, capability - last, riskiest). Invariants live in the epic. Reorder scrambled lines using bounding boxes before parsing. ## Anchors - `OcrBox` (`OcrResult.cs:11`) - the X/Y/Width/Height to sort on. - Current code trusts line order except for the total's `Box.Y` (`ReceiptParser.cs:112,128`). - Seed fixture: `backend/tests/BillSplitter.Tests/Fixtures/receipts/westminster-column-drift`. ## Steps 1. Add a pre-pass sorting lines by `Box.Y` then `Box.X` with a row tolerance. 2. Tolerance-gate it: only reorder when boxes prove drift; leave already-ordered receipts alone. ## Done - [ ] New drift fixture(s) demonstrating recovery. - [ ] Existing corpus green.
Sign in to join this conversation.
No description provided.