fix: address code review findings
- Strip standalone reissue keywords (remaster/remastered/remix/deluxe/ expanded/edition/reissue/anniversary/bonus) regardless of brackets so non-parenthesized remasters still match the plain local title above the 0.85 threshold (was falsely reported missing). - Fix TestAppRun_ScanLogsMissingReleases to verify run() performs the scan itself (capture its log output) instead of re-running ScanAll independently, which passed even if run() were a no-op. - Fix TestSimilarity misleading cases that downgraded to a <0.85 range check with dead want/epsilon fields; assert actual computed scores.
This commit is contained in:
@@ -17,6 +17,12 @@ var (
|
||||
bracketRe = regexp.MustCompile(`\[[^\]]*\]`)
|
||||
parenRe = regexp.MustCompile(`\([^)]*\)`)
|
||||
yearRe = regexp.MustCompile(`\b[0-9]{4}\b`)
|
||||
// keywordRe strips common reissue/edition keywords that appear WITHOUT
|
||||
// brackets or parentheses (e.g. "The Wall 2011 Remaster", "Album 2020
|
||||
// Remastered", "X Deluxe"). MusicBrainz release-group titles frequently
|
||||
// carry these as free-standing words; they must be removed so a remaster
|
||||
// still matches the plain local title above the fuzzy threshold.
|
||||
keywordRe = regexp.MustCompile(`(?i)\b(remaster|remastered|remix|deluxe|expanded|edition|reissue|anniversary|bonus)\b`)
|
||||
spaceRe = regexp.MustCompile(`\s+`)
|
||||
// bareYearRe matches a title that is *only* a single year (with optional
|
||||
// surrounding whitespace), e.g. "1989" or "2112". Used to decide whether a
|
||||
@@ -46,6 +52,12 @@ func NormalizeString(s string) string {
|
||||
// Remove parenthesized content (e.g., (Deluxe), (Remastered))
|
||||
s = parenRe.ReplaceAllString(s, "")
|
||||
|
||||
// Remove standalone reissue/edition keywords (e.g. "2011 Remaster",
|
||||
// "2020 Remastered", "Deluxe"). These appear without brackets/parens
|
||||
// in many MusicBrainz titles and must be stripped so a remaster still
|
||||
// matches the plain local title above the fuzzy threshold.
|
||||
s = keywordRe.ReplaceAllString(s, "")
|
||||
|
||||
// Remove years (any 4-digit number). If stripping the year
|
||||
// empties the entire string, decide what to keep:
|
||||
// - A bare year title (e.g. "1989", "2112") has no other words, so keep
|
||||
|
||||
Reference in New Issue
Block a user