fix: bump costco-go to v0.3.10 (word-overlap discount matching)#24
Merged
Conversation
v0.3.10 adds a word-overlap fallback to NetDiscounts that resolves the DURACELL AAA / AAA BATTERY case: the coupon's /AAA BATTERY token and the product description 'DURACELL AAA' share no substring relationship, but both contain the word 'AAA', which is now used to match them. Also tightens the v0.3.9 substring reverse-contains guard so a short item description can't vacuously match a long coupon reference.
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.
Changes
Bumps
costco-gofromv0.3.9→v0.3.10.Why
After merging #23 (which introduced
NetDiscounts), the orphaned-discount warning was still firing on real receipt21134301000462605131128:A verbose debug dump of the raw receipt items revealed the actual data:
"DURACELL AAA"shares no substring with"AAA BATTERY", so neither the exact-description nor the substring fallbacks in v0.3.9 could match them.Fix (in costco-go v0.3.10)
Added a 4th matching strategy — word-overlap scoring — that scores candidate items by how many significant words (≥3 chars) from the coupon reference appear in the item description, then picks the highest-scoring match. The shared token
AAA(len=3) bridges"DURACELL AAA"and"AAA BATTERY".Also tightened the v0.3.9 substring reverse-contains guard (
len(desc) >= len(ref)/2) to prevent short item descriptions from vacuously matching long coupon tokens.Checklist
go test ./... -race)