feat(match): rarity-weighted, fuzzy, combination-aware term scorer (A4/A10)#25
Merged
officialCodeWork merged 1 commit intoJul 14, 2026
Merged
Conversation
…4/A10)
Replace matchComponentsByText with a real scorer (TRACKER step 4.1):
- Rarity weighting: each term's weight is its inverse document frequency across
the graph, so a lone "Save" (everywhere) ties → honest `ambiguous`, while one
distinctive term ("Card number") breaks the tie → `ok`.
- Fuzzy tokens: long tokens match within a small, length-scaled edit distance,
so OCR slips ("Acount Reconcilliation") still land the right component; short
common tokens stay exact so noise can't collide unrelated matches.
- Combination bonus: several distinct terms co-occurring in one component
outrank the same terms scattered across many.
- Order-sensitive phrase matching: "Order deleted" no longer equals
"Delete order" (a bag-of-tokens bug caught by the a9 fixture). Match evidence
keeps its i18n-key / branch provenance.
New text utils: editDistance (bounded Levenshtein), fuzzyTokenMatch, tokenize.
Eval harness gains GoldenQuery.topK (the honest top-3 bar for OCR). Fixture
a10-ocr-noise (misspelled distinctive text → correct top-1). 36 core + 92 parser
tests pass; eval green (precision/recall 1.000, match accuracy 1.000).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Step 4.1 — Term matching v2 (opens Phase 4)
Failure modes A4 / A7 / A10.
matchComponentsByTextis now a real scorer over rendered text instead of raw overlap."Save"(in every form) ties → honestambiguous; one distinctive term ("Card number") dominates →ok."Acount Reconcilliation") still land the right component. Short common tokens stay exact (save ≠ safe), so noise can't collide unrelated matches."Order deleted" ≠ "Delete order"(a bag-of-tokens bug the a9 fixture caught). Match evidence keeps its i18n-key / branch provenance.New primitives
editDistance(bounded Levenshtein),fuzzyTokenMatch,tokenizein core text utils. Eval harness gainsGoldenQuery.topK— the honest top-3 bar for OCR-noisy input.Eval
Fixture a10-ocr-noise: four components with distinctive long words; misspelled OCR queries resolve to the right component (top-1, well within top-3). a4 (generic "Save") stays green.
Verification
pnpm eval: green, precision/recall 1.000, match accuracy 1.000.🤖 Generated with Claude Code