Skip to content

OCR hint regex: capture groups, reverse separators, glued currency, extract lock #430

Description

@schatt

Problem

#420 made word hints match Total: / sum= when $ is in the same field. The /2 review of that landing found leftover gaps:

  1. Capture layout vs extraction — hint-first alternatives capture only the number. OCRLabelAnchoredExtraction still uses hintGroupIndex = numberGroupIndex - 1, so hintLength / layout hint substring are 0. Match exists; longer-hint disambiguation and line-proximity scoring do not see the hint.
  2. Tests lock range(of:) onlyTotal: 90.22 is not asserted through extract / applyStructuredExtraction.
  3. Reverse arm still uses one \\s+ for every hint (90.22: total, 90.22=sum miss).
  4. Glued $90.22 — currency separator requires \\s+.
  5. $/gal must stay a word hint (colon/equals), not the currency-symbol set.

Expected

  • Hint-first alternatives are (hint)(?:separator)(number) so adjacent capture groups are hint then number.
  • Number-first uses the same per-hint separators.
  • Currency symbols ($€£¥) allow optional words and optional space ($90.22, $ This Sale 90.22).
  • OCRLabelAnchoredExtraction.extract returns totalCost=90.22 for Total: 90.22 when $ is in ocrHints.
  • hintLength for that match is total.count (5).
  • $/gal: 7.22 still matches as a word hint.

Related

#420, #382, #282

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtesting

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions