From feb1d8631d579c5f6b20018ab95f75a6c9f29d72 Mon Sep 17 00:00:00 2001 From: Tai Lee Date: Sat, 25 May 2013 17:59:00 +1000 Subject: [PATCH] Move match distance weights to an undocumented configuration setting. --- beets/autotag/match.py | 24 ++++++++++++------------ beets/config_default.yaml | 13 +++++++++++++ 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/beets/autotag/match.py b/beets/autotag/match.py index a417bfe35..ce194d326 100644 --- a/beets/autotag/match.py +++ b/beets/autotag/match.py @@ -31,29 +31,29 @@ from beets.autotag import hooks # Distance parameters. # Text distance weights: proportions on the normalized intuitive edit # distance. -ARTIST_WEIGHT = 3.0 -ALBUM_WEIGHT = 3.0 +ARTIST_WEIGHT = config['match']['weight']['artist'].as_number() +ALBUM_WEIGHT = config['match']['weight']['album'].as_number() # The weight of the entire distance calculated for a given track. -TRACK_WEIGHT = 1.0 +TRACK_WEIGHT = config['match']['weight']['track'].as_number() # The weight of a missing track. -MISSING_WEIGHT = 0.9 +MISSING_WEIGHT = config['match']['weight']['missing'].as_number() # The weight of an extra (unmatched) track. -UNMATCHED_WEIGHT = 0.6 +UNMATCHED_WEIGHT = config['match']['weight']['unmatched'].as_number() # These distances are components of the track distance (that is, they # compete against each other but not ARTIST_WEIGHT and ALBUM_WEIGHT; # the overall TRACK_WEIGHT does that). -TRACK_TITLE_WEIGHT = 3.0 +TRACK_TITLE_WEIGHT = config['match']['weight']['track_title'].as_number() # Used instead of a global artist penalty for various-artist matches. -TRACK_ARTIST_WEIGHT = 2.0 +TRACK_ARTIST_WEIGHT = config['match']['weight']['track_artist'].as_number() # Added when the indices of tracks don't match. -TRACK_INDEX_WEIGHT = 1.0 +TRACK_INDEX_WEIGHT = config['match']['weight']['track_index'].as_number() # Track length weights: no penalty before GRACE, maximum (WEIGHT) # penalty at GRACE+MAX discrepancy. -TRACK_LENGTH_GRACE = 10 -TRACK_LENGTH_MAX = 30 -TRACK_LENGTH_WEIGHT = 2.0 +TRACK_LENGTH_GRACE = config['match']['weight']['track_length_grace'].as_number() +TRACK_LENGTH_MAX = config['match']['weight']['track_length_max'].as_number() +TRACK_LENGTH_WEIGHT = config['match']['weight']['track_length'].as_number() # MusicBrainz track ID matches. -TRACK_ID_WEIGHT = 5.0 +TRACK_ID_WEIGHT = config['match']['weight']['track_id'].as_number() # Parameters for string distance function. # Words that can be moved to the end of a string using a comma. diff --git a/beets/config_default.yaml b/beets/config_default.yaml index 15397908b..d061b983f 100644 --- a/beets/config_default.yaml +++ b/beets/config_default.yaml @@ -72,3 +72,16 @@ match: partial: medium tracklength: strong tracknumber: strong + weight: + artist: 3.0 + album: 3.0 + track: 1.0 + missing: 0.9 + unmatched: 0.6 + track_title: 3.0 + track_artist: 2.0 + track_index: 1.0 + track_length_grace: 10 + track_length_max: 30 + track_length: 2.0 + track_id: 5.0