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)
def test_closest_tie_with_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_4.txt") result = ds.find_closest_artist(artist_to_songfiles_map, query, ngrams=2) expected = ["artist_1", "artist_2"] self.assertListEqual(result, expected)
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")
def test_closest_bigrams(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_bigrams = ds.find_closest_artist(artist_to_songfiles_map, query, use_bigrams=True) expected_with_bigrams = [] result_without_bigrams = ds.find_closest_artist( artist_to_songfiles_map, query) expected_without_bigrams = ["artist_2"] self.assertListEqual(result_without_bigrams, expected_without_bigrams) self.assertListEqual(result_with_bigrams, expected_with_bigrams)
def test_prep_hello_world(self): expected = ["hello", "world", "hello"] result = ds.load_file("tests/student_tests/hello_world.txt") self.assertEqual(result, expected)
def test_prep_all_whitespace(self): expected = ["hello", "it", "is", "me", "mario"] result = ds.load_file("tests/student_tests/test1c.txt") self.assertEqual(result, expected)
def test_prep_1a(self): expected = a1 result = ds.load_file("tests/student_tests/test1a.txt") self.assertEqual(result, expected)