mirror of
https://github.com/beetbox/beets.git
synced 2025-12-30 20:42:37 +01:00
&/and equivalent in string distance
This commit is contained in:
parent
77187baa8b
commit
c2fd535047
3 changed files with 22 additions and 4 deletions
1
NEWS
1
NEWS
|
|
@ -33,6 +33,7 @@
|
|||
to the @listen decorator (Thanks again, Lugoues!)
|
||||
* In path formats, $albumartist now falls back to $artist (as well as
|
||||
the other way around).
|
||||
* When autotagging, "and" is considered equal to "&".
|
||||
* Fix some crashes when deleting files that don't exist.
|
||||
* Fix adding individual tracks in BPD.
|
||||
* Fix crash when ~/.beetsconfig does not exist.
|
||||
|
|
|
|||
|
|
@ -74,6 +74,10 @@ SD_PATTERNS = [
|
|||
(r'\[.*?\]', 0.3),
|
||||
(r'(, )?(pt\.|part) .+', 0.2),
|
||||
]
|
||||
# Replacements to use before testing distance.
|
||||
SD_REPLACE = [
|
||||
(r'&', 'and'),
|
||||
]
|
||||
|
||||
# Artist signals that indicate "various artists".
|
||||
VA_ARTISTS = (u'', u'various artists', u'va', u'unknown')
|
||||
|
|
@ -134,6 +138,11 @@ def string_dist(str1, str2):
|
|||
str1 = '%s %s' % (word, str1[:-len(word)-2])
|
||||
if str2.endswith(', %s' % word):
|
||||
str2 = '%s %s' % (word, str2[:-len(word)-2])
|
||||
|
||||
# Perform a couple of basic normalizing substitutions.
|
||||
for pat, repl in SD_REPLACE:
|
||||
str1 = re.sub(pat, repl, str1)
|
||||
str2 = re.sub(pat, repl, str2)
|
||||
|
||||
# Change the weight for certain string portions matched by a set
|
||||
# of regular expressions. We gradually change the strings and build
|
||||
|
|
|
|||
|
|
@ -403,10 +403,14 @@ class ApplyCompilationTest(unittest.TestCase):
|
|||
|
||||
def test_mb_albumartistid_applied(self):
|
||||
autotag.apply_metadata(self.items, self.info)
|
||||
self.assertEqual(self.items[0].mb_albumartistid, '89ad4ac3-39f7-470e-963a-56509c546377')
|
||||
self.assertEqual(self.items[1].mb_albumartistid, '89ad4ac3-39f7-470e-963a-56509c546377')
|
||||
self.assertEqual(self.items[0].mb_artistid, 'a05686fc-9db2-4c23-b99e-77f5db3e5282')
|
||||
self.assertEqual(self.items[1].mb_artistid, '80b3cf5e-18fe-4c59-98c7-e5bb87210710')
|
||||
self.assertEqual(self.items[0].mb_albumartistid,
|
||||
'89ad4ac3-39f7-470e-963a-56509c546377')
|
||||
self.assertEqual(self.items[1].mb_albumartistid,
|
||||
'89ad4ac3-39f7-470e-963a-56509c546377')
|
||||
self.assertEqual(self.items[0].mb_artistid,
|
||||
'a05686fc-9db2-4c23-b99e-77f5db3e5282')
|
||||
self.assertEqual(self.items[1].mb_artistid,
|
||||
'80b3cf5e-18fe-4c59-98c7-e5bb87210710')
|
||||
|
||||
def test_va_flag_cleared_does_not_set_comp(self):
|
||||
autotag.apply_metadata(self.items, self.info)
|
||||
|
|
@ -487,6 +491,10 @@ class StringDistanceTest(unittest.TestCase):
|
|||
dist = autotag.string_dist('Untitled', '[Untitled]')
|
||||
self.assertEqual(dist, 0.0)
|
||||
|
||||
def test_ampersand_expansion(self):
|
||||
dist = autotag.string_dist('And', '&')
|
||||
self.assertEqual(dist, 0.0)
|
||||
|
||||
def suite():
|
||||
return unittest.TestLoader().loadTestsFromName(__name__)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue