Exemplo n.º 1
0
    def track_distance(self, item, info):
        last_data = match(item.path)
        if not last_data:
            # Match failed.
            return 0.0, 0.0

        dist, dist_max = 0.0, 0.0

        # Track title distance.
        dist += autotag.string_dist(last_data['title'],
                                 info['title']) \
                * autotag.TRACK_TITLE_WEIGHT
        dist_max += autotag.TRACK_TITLE_WEIGHT

        # MusicBrainz track ID.
        if last_data['track_mbid']:
            # log.debug('Last track ID match: %s/%s' %
            #           (last_data['track_mbid'], track_data['id']))
            if last_data['track_mbid'] != track_data['id']:
                dist += autotag.TRACK_ID_WEIGHT
            dist_max += autotag.TRACK_ID_WEIGHT

        # log.debug('Last data: %s; distance: %f' %
        #           (str(last_data), dist/dist_max if dist_max > 0.0 else 0.0))

        return dist * DISTANCE_SCALE, dist_max * DISTANCE_SCALE
Exemplo n.º 2
0
    def track_distance(self, item, info):
        last_data = match(item.path)
        if not last_data:
            # Match failed.
            return 0.0, 0.0

        dist, dist_max = 0.0, 0.0

        # Track title distance.
        dist += autotag.string_dist(last_data['title'],
                                 info['title']) \
                * autotag.TRACK_TITLE_WEIGHT
        dist_max += autotag.TRACK_TITLE_WEIGHT
        
        # MusicBrainz track ID.
        if last_data['track_mbid']:
            # log.debug('Last track ID match: %s/%s' %
            #           (last_data['track_mbid'], track_data['id']))
            if last_data['track_mbid'] != track_data['id']:
                dist += autotag.TRACK_ID_WEIGHT
            dist_max += autotag.TRACK_ID_WEIGHT

        # log.debug('Last data: %s; distance: %f' %
        #           (str(last_data), dist/dist_max if dist_max > 0.0 else 0.0))

        return dist * DISTANCE_SCALE, dist_max * DISTANCE_SCALE
Exemplo n.º 3
0
    def album_distance(self, items, info):
        last_artist, last_artist_id = get_cur_artist(items)

        # Compare artist to MusicBrainz metadata.
        dist, dist_max = 0.0, 0.0
        if last_artist:
            dist += autotag.string_dist(last_artist, info['artist']) \
                    * autotag.ARTIST_WEIGHT
            dist_max += autotag.ARTIST_WEIGHT

        log.debug('Last artist (%s/%s) distance: %f' %
                  (last_artist, info['artist'], dist/dist_max))

        #fixme: artist MBID currently ignored (as in vanilla tagger)
        return dist, dist_max
Exemplo n.º 4
0
    def album_distance(self, items, info):
        last_artist, last_artist_id = get_cur_artist(items)

        # Compare artist to MusicBrainz metadata.
        dist, dist_max = 0.0, 0.0
        if last_artist:
            dist += autotag.string_dist(last_artist, info['artist']) \
                    * autotag.ARTIST_WEIGHT
            dist_max += autotag.ARTIST_WEIGHT

        log.debug('Last artist (%s/%s) distance: %f' %
                  (last_artist, info['artist'],
                   dist / dist_max if dist_max > 0.0 else 0.0))

        #fixme: artist MBID currently ignored (as in vanilla tagger)
        return dist, dist_max
Exemplo n.º 5
0
 def test_solo_pattern(self):
     # Just make sure these don't crash.
     autotag.string_dist('The ', '')
     autotag.string_dist('(EP)', '(EP)')
     autotag.string_dist(', An', '')
Exemplo n.º 6
0
 def test_postfix_an(self):    
     dist = autotag.string_dist('An Album Title', 'Album Title, An')
     self.assertEqual(dist, 0.0)
Exemplo n.º 7
0
 def test_postfix_the(self):    
     dist = autotag.string_dist('The Song Title', 'Song Title, The')
     self.assertEqual(dist, 0.0)
Exemplo n.º 8
0
 def test_ep_label_has_zero_weight(self):    
     dist = autotag.string_dist('My Song (EP)', 'My Song')
     self.assertEqual(dist, 0.0)
Exemplo n.º 9
0
 def test_parens_have_lower_weight(self):    
     dist1 = autotag.string_dist('One .Two.', 'One')
     dist2 = autotag.string_dist('One (Two)', 'One')
     self.assert_(dist2 < dist1)
Exemplo n.º 10
0
 def test_case_ignored(self):
     dist = autotag.string_dist('Some String', 'sOME sTring')
     self.assertEqual(dist, 0.0)
Exemplo n.º 11
0
 def test_different_strings(self):
     dist = autotag.string_dist('Some String', 'Totally Different')
     self.assertNotEqual(dist, 0.0)
Exemplo n.º 12
0
 def test_featured_has_lower_weight(self):    
     dist1 = autotag.string_dist('My Song blah Someone', 'My Song')
     dist2 = autotag.string_dist('My Song feat Someone', 'My Song')
     self.assert_(dist2 < dist1)
Exemplo n.º 13
0
 def test_ep_label_has_zero_weight(self):    
     dist = autotag.string_dist('My Song (EP)', 'My Song')
     self.assertEqual(dist, 0.0)
Exemplo n.º 14
0
 def test_brackets_have_lower_weight(self):    
     dist1 = autotag.string_dist('One .Two.', 'One')
     dist2 = autotag.string_dist('One [Two]', 'One')
     self.assert_(dist2 < dist1)
Exemplo n.º 15
0
 def test_parens_have_lower_weight(self):    
     dist1 = autotag.string_dist('One .Two.', 'One')
     dist2 = autotag.string_dist('One (Two)', 'One')
     self.assert_(dist2 < dist1)
Exemplo n.º 16
0
 def test_leading_the_has_lower_weight(self):    
     dist1 = autotag.string_dist('XXX Band Name', 'Band Name')
     dist2 = autotag.string_dist('The Band Name', 'Band Name')
     self.assert_(dist2 < dist1)
Exemplo n.º 17
0
 def test_case_ignored(self):
     dist = autotag.string_dist('Some String', 'sOME sTring')
     self.assertEqual(dist, 0.0)
Exemplo n.º 18
0
 def test_punctuation_ignored(self):
     dist = autotag.string_dist('Some String', 'Some.String!')
     self.assertEqual(dist, 0.0)
Exemplo n.º 19
0
 def test_different_strings(self):
     dist = autotag.string_dist('Some String', 'Totally Different')
     self.assertNotEqual(dist, 0.0)
Exemplo n.º 20
0
 def test_postfix_the(self):    
     dist = autotag.string_dist('The Song Title', 'Song Title, The')
     self.assertEqual(dist, 0.0)
Exemplo n.º 21
0
 def test_punctuation_ignored(self):
     dist = autotag.string_dist('Some String', 'Some.String!')
     self.assertEqual(dist, 0.0)
Exemplo n.º 22
0
 def test_postfix_a(self):    
     dist = autotag.string_dist('A Song Title', 'Song Title, A')
     self.assertEqual(dist, 0.0)
Exemplo n.º 23
0
 def test_leading_the_has_lower_weight(self):    
     dist1 = autotag.string_dist('XXX Band Name', 'Band Name')
     dist2 = autotag.string_dist('The Band Name', 'Band Name')
     self.assert_(dist2 < dist1)
Exemplo n.º 24
0
 def test_postfix_an(self):    
     dist = autotag.string_dist('An Album Title', 'Album Title, An')
     self.assertEqual(dist, 0.0)
Exemplo n.º 25
0
 def test_brackets_have_lower_weight(self):    
     dist1 = autotag.string_dist('One .Two.', 'One')
     dist2 = autotag.string_dist('One [Two]', 'One')
     self.assert_(dist2 < dist1)
Exemplo n.º 26
0
 def test_empty_strings(self):
     dist = autotag.string_dist('', '')
     self.assertEqual(dist, 0.0)
Exemplo n.º 27
0
 def test_featured_has_lower_weight(self):    
     dist1 = autotag.string_dist('My Song blah Someone', 'My Song')
     dist2 = autotag.string_dist('My Song feat Someone', 'My Song')
     self.assert_(dist2 < dist1)
Exemplo n.º 28
0
 def test_solo_pattern(self):
     # Just make sure these don't crash.
     autotag.string_dist('The ', '')
     autotag.string_dist('(EP)', '(EP)')
     autotag.string_dist(', An', '')
Exemplo n.º 29
0
 def test_postfix_a(self):    
     dist = autotag.string_dist('A Song Title', 'Song Title, A')
     self.assertEqual(dist, 0.0)
Exemplo n.º 30
0
 def test_heuristic_does_not_harm_distance(self):
     dist = autotag.string_dist('Untitled', '[Untitled]')
     self.assertEqual(dist, 0.0)
Exemplo n.º 31
0
 def test_empty_strings(self):
     dist = autotag.string_dist('', '')
     self.assertEqual(dist, 0.0)
Exemplo n.º 32
0
 def test_accented_characters(self):
     dist = autotag.string_dist(u'\xe9\xe1\xf1', u'ean')
     self.assertEqual(dist, 0.0)
Exemplo n.º 33
0
 def test_heuristic_does_not_harm_distance(self):
     dist = autotag.string_dist('Untitled', '[Untitled]')
     self.assertEqual(dist, 0.0)
Exemplo n.º 34
0
 def test_equal_strings(self):
     dist = autotag.string_dist('Some String', 'Some String')
     self.assertEqual(dist, 0.0)
Exemplo n.º 35
0
 def test_ampersand_expansion(self):
     dist = autotag.string_dist('And', '&')
     self.assertEqual(dist, 0.0)
Exemplo n.º 36
0
 def test_equal_strings(self):
     dist = autotag.string_dist('Some String', 'Some String')
     self.assertEqual(dist, 0.0)