subwave: fix matcher scoring for composite credits/subtitles, add 3 more 1995 shows
score_candidate compared library tags verbatim against chart artist/title, so a
reissue's composite artist credit (e.g. "Green Day • Billie Joe Armstrong, Mike
Dirnt, & Tre Cool") or a dropped subtitle ("Sour Times" vs "Sour Times (Nobody
Loves Me)") could push an otherwise-correct match just under the score
threshold. Added whole-word substring containment as a scoring boost for both
fields, which recovered several real misses.
Also adds three more 1995 Tunecaster Rock Top 30 weeks (Jan 14, Jun 10, Dec 16)
alongside the existing Oct 28 show, cross-checked against it for exact-track
duplicates (swapped for a different real single by the same artist, or dropped
where none existed in the library).
Claude-Session: https://claude.ai/code/session_01L7Rwa6guD5wK8F8tWQwcJX
This commit is contained in:
@@ -158,8 +158,28 @@ def similarity(a, b):
|
||||
return difflib.SequenceMatcher(None, normalize(a), normalize(b)).ratio()
|
||||
|
||||
|
||||
def contains_normalized(a, b):
|
||||
"""True if the normalized forms of a/b contain one another as whole words.
|
||||
|
||||
Handles library tags that carry extra baggage a chart title/artist won't --
|
||||
reissue composite credits ("Green Day • Billie Joe Armstrong, Mike Dirnt,
|
||||
& Tre Cool") or a subtitle the library dropped ("Sour Times" vs "Sour Times
|
||||
(Nobody Loves Me)") -- without this a correct match can score just under
|
||||
the threshold on artist or title alone even though one string is clearly
|
||||
the other plus extra text.
|
||||
"""
|
||||
na, nb = f" {normalize(a)} ", f" {normalize(b)} "
|
||||
return bool(na.strip()) and bool(nb.strip()) and (na in nb or nb in na)
|
||||
|
||||
|
||||
def score_candidate(song, artist, title):
|
||||
return similarity(song.get("title", ""), title) * 0.6 + similarity(song.get("artist", ""), artist) * 0.4
|
||||
title_score = similarity(song.get("title", ""), title)
|
||||
if contains_normalized(song.get("title", ""), title):
|
||||
title_score = max(title_score, 0.9)
|
||||
artist_score = similarity(song.get("artist", ""), artist)
|
||||
if contains_normalized(song.get("artist", ""), artist):
|
||||
artist_score = 1.0
|
||||
return title_score * 0.6 + artist_score * 0.4
|
||||
|
||||
|
||||
def match_track(nd_cfg, artist, title, min_score):
|
||||
|
||||
Reference in New Issue
Block a user