refactor(parser): extract line classifier #91

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

Parent: #77 (Phase A, step 3). Invariants live in the epic.

Extract line classification into its own component.

Anchors

  • Keyword helpers: ReceiptParser.cs:293-317 - IsSubtotal, IsItemCount,
    IsCategoryRollup, IsTax, IsTaxBreakdown, IsTip, IsService,
    IsTotal, IsPaymentNoise.
  • Backing regexes: CategoryRollup() (42), ItemCount() (73),
    ServiceLabel() (48).

Steps

  1. Add ILineClassifier + KeywordClassifier in Parsing/Classification,
    mapping a line to LineType.
  2. Engine consumes LineType in place of the inline helper calls at
    ReceiptParser.cs:121 and 139-195.

Done

  • Corpus 100% green, byte-identical output.
  • Classification logic lives in one place, not scattered through Parse.
Parent: #77 (Phase A, step 3). Invariants live in the epic. Extract line classification into its own component. ## Anchors - Keyword helpers: `ReceiptParser.cs:293-317` - `IsSubtotal`, `IsItemCount`, `IsCategoryRollup`, `IsTax`, `IsTaxBreakdown`, `IsTip`, `IsService`, `IsTotal`, `IsPaymentNoise`. - Backing regexes: `CategoryRollup()` (42), `ItemCount()` (73), `ServiceLabel()` (48). ## Steps 1. Add `ILineClassifier` + `KeywordClassifier` in `Parsing/Classification`, mapping a line to `LineType`. 2. Engine consumes `LineType` in place of the inline helper calls at `ReceiptParser.cs:121` and `139-195`. ## Done - [ ] Corpus 100% green, byte-identical output. - [ ] Classification logic lives in one place, not scattered through `Parse`.
Sign in to join this conversation.
No description provided.