예제 #1
0
 def test_closest_ngrams(self):
     artists = ["artist_1", "artist_2"]
     prefix = "tests/student_tests"
     artist_to_songfiles_map = {
         artist: absolute_file_paths(os.path.join(prefix, artist)) for artist in artists
     }
     query = ds.load_file(prefix + "/mystery_lyrics/mystery_5.txt")
     result_with_ngrams = ds.find_closest_artist(artist_to_songfiles_map, query, ngrams=3)
     expected_with_ngrams = []
     result_without_ngrams = ds.find_closest_artist(artist_to_songfiles_map, query, ngrams=1)
     expected_without_ngrams = ["artist_2"]
     self.assertListEqual(result_without_ngrams, expected_without_ngrams)
     self.assertListEqual(result_with_ngrams, expected_with_ngrams)
예제 #2
0
 def test_closest_none(self):
     artists = ["artist_1", "artist_2"]
     prefix = "tests/student_tests"
     artist_to_songfiles_map = {}
     query = ds.load_file(prefix + "/mystery_lyrics/mystery_1.txt")
     result = ds.find_closest_artist(artist_to_songfiles_map, query)
     expected = []
     self.assertListEqual(result, expected)
예제 #3
0
 def test_closest_3(self):
     artists = ["artist_1", "artist_2"]
     prefix = "tests/student_tests"
     artist_to_songfiles_map = {
         artist: absolute_file_paths(os.path.join(prefix, artist))
         for artist in artists
     }
     query = ds.load_file(prefix + "/mystery_lyrics/mystery_1.txt")
     result = ds.find_closest_artist(artist_to_songfiles_map, query)
     expected = ["artist_1"]
     self.assertListEqual(result, expected)
예제 #4
0
 def test_closest_rounded(self):
     artists = ["simple_artist_1", "simple_artist_2"]
     prefix = "tests/student_tests"
     artist_to_songfiles_map = {
         artist: absolute_file_paths(os.path.join(prefix, artist))
         for artist in artists
     }
     query = ds.load_file(prefix + "/simple_mystery/simple_mystery_2.txt")
     expected = ["simple_artist_1", "simple_artist_2"]
     result = ds.find_closest_artist(artist_to_songfiles_map, query)
     self.assertListEqual(
         result, expected,
         "check that rounded simmilarity score is being used")