def songComparison(model, song1, artist1, song2, artist2): genius = Genius(API_Keys.genius_access_token) genius.timeout = 15 genius.sleep_time = 2 lyrics1 = getLyrics(song1, artist1, genius) lyrics2 = getLyrics(song2, artist2, genius) if lyrics1 is None: print(song1) return (None) if lyrics2 is None: print(song2) return (None) docs = [lyrics1, lyrics2] dist = getSongDivergence(model, docs) return (dist)
if dist <= .2 and song1[2] == song2[2]: return 1 if dist > .2 and song1[2] != song2[2]: return 1 else: return 0 if __name__ == '__main__': trainedSongs = [] untrainedSongs = [] songLyrics = {} genius = Genius(genius_access_token) genius.timeout = 15 genius.sleep_time = 2 with open("testSongList.csv", mode='r', newline='') as songs: songReader = csv.reader(songs, delimiter=',', quotechar='"') next(songReader, None) for song in songReader: doc = compare.getLyrics(song[0], song[1], genius) songLyrics[song[0]] = doc if song[3] == 'y': trainedSongs.append(song) else: untrainedSongs.append(song) with open("outputs/testResults.csv", mode='a', newline='') as results: resultsWriter = csv.writer(results, delimiter=',', quotechar='"')