Fix OCR set-code position bug + collector-number leading zeros (no-match autopsy) - #23
Merged
Merged
Conversation
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016i9S7LQsCL3FGaih3ZTRBJ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Post-merge Hold #1 of the pre-scale program for Stage 8 (local printing-ID pilot): classified
all 176 OCR "parsed-but-no-match" cases from the real pilot run and found two real, contained
parser bugs, both fixed here.
1. Set-code token position.
parse_collector_line's set-code search took the FIRSTplausible 3-5 char token anywhere in the line - which is virtually always leading noise (a
watermark, a rarity-letter glyph merging with a stray digit into something code-shaped) rather
than the real set code, which a genuine card layout always prints AFTER the collector number.
Fixed to search the text after the number first, falling back to before only if nothing
plausible follows.
2. Collector-number leading zeros. OCR frequently reads a spurious leading zero ("0093" for
a real "93") that literal string comparison silently rejected. Fixed via
_normalize_collector_number(strip leading zeros, keep any trailing variant letter), appliedsymmetrically to both the parsed reading and every candidate's stored value.
Yield delta
Precisely measured by re-parsing the exact same 176 raw texts with both the old and new logic
(isolating this cohort from 3 cards that already matched under the old parser):
47/176 (26.7%) now match.
Projected full-engine impact: OCR yield 77/300 (25.7%) -> ~124/300 (41.3%), a ~60% relative
improvement, from this small parser fix.
Confirmed live via a real (non-simulated)
--dry-runafterward: 62/250 votes on a freshselection window, consistent with the isolated measurement.
Of the 129 still-unfixed cases: only 2/176 (1.1%) are genuinely-missing printings; the
remaining 127/176 (72.2%) are true OCR garbage with no salvageable signal - a meaningful
fraction traceable to one specific custom-frame Drive source (
Source pk=1, "WilfordGrimley")whose non-standard branding text sits inside the collector-line crop region and defeats OCR
outright.
Cross-checked against the separate 1,097-card filename tag-gap census: NOT the same root
cause. All 1,097 have a fully recognized
CanonicalExpansioncode - that gap is aname-matching problem (many are
(Front)/(Back)filename-parsing artifacts on basic lands),unrelated to this OCR fix. Two separate issues, not one fix arriving twice - the D2.5
deterministic tier is not implied here and was not built.
Test plan
TestOcrParsing,TestOcrValidationRail), all passing--dry-runagainst live production data confirms the projected yield improvementCo-Authored-By: Claude Sonnet 5 noreply@anthropic.com