Пример #1
0
def save_genres(song_id, recording):
    """Save the tags for recording `recording` as genres for song
    `song_id`."""
    song_genres = []

    if 'tag-list' in recording:
        for tag in recording['tag-list']:
            if int(tag['count']) == 0:  # tag not applied
                continue
            genre_id = genres.find(tag['name'])
            if genre_id != -1 and genre_id not in song_genres:
                db.save('song_genre', (song_id, genre_id))
                song_genres.append(genre_id)

    # put song in 'Other' category if no genres were found
    if len(song_genres) == 0:
        db.save('song_genre', (song_id, genres.OTHER))
Пример #2
0
 def test_tag_vs_genre(self):
     result = find("Miles Davis. Jit")
     assert "jit" in result
Пример #3
0
 def test_ranking(self):
     result = find("Benga. House")
     assert "benga" in result
Пример #4
0
 def test_tag_vs_genre_check(self):
     result = find("Miles Davis. Miles Davis. Miles Davis. Techno. Techno.")
     assert "jazz" in result
     assert len(result) == 1
Пример #5
0
 def test_genre_tag_occurence(self):
     result = find("Ska jazz. Ska jazz. The best jazz player is Miles Davis. \
     Miles Davis. Miles Davis")
     assert "jazz" == result[0]
Пример #6
0
 def test_slash_separator(self):
     result = find("blues/Random word test")
     assert "blues" in result
Пример #7
0
 def test_between_words(self):
     result = find("Hip-hop is a genre")
     assert "hip hop" in result
Пример #8
0
 def test_single_match(self):
     result = find("This is a good example of techno. Hello techno.")
     assert "techno" in result
Пример #9
0
 def test_tag_match(self):
     result = find("In this text we have a Country Test Tag")
     assert "country" in result
Пример #10
0
 def test_comment_data(self):
     result = find("#comment")
     assert "#comment" not in result
Пример #11
0
 def test_highest_occurence_return_genre(self):
     result = find("ska, Techno, Ska")
     assert "ska" in result
Пример #12
0
 def test_not_existing_genre(self):
     result = find("Lorem ipsum dolum test")
     assert len(result) == 0
Пример #13
0
 def test_conflicting_genres(self):
     result = find("Dance Hall and Reggae-Techno")
     assert "techno" not in result
Пример #14
0
 def test_multiple_and_invalid(self):
     result = find("KingstonDance Hall and Reggae")
     assert "dance hall" not in result
Пример #15
0
 def test_multiple_match(self):
     result = find("This is Dance Hall. Sounds like a mix of Merengue")
     assert "dance hall" in result
Пример #16
0
 def test_genre_ranking(self):
     result = find("In this house, we play jazz")
     assert "jazz" in result
Пример #17
0
 def test_escaped_genre(self):
     result = find("For over a decade, Los Angeles singer/songwriter \
         Jhené Aiko has skirted the periphery of R&B stardom")
     assert "r&b" in result
Пример #18
0
 def test(self):
     result = find(review[1])
     found = all((w in result for w in review[0]))
     self.assertTrue(found)