Created
July 9, 2018 23:40
-
-
Save Ram-N/96ea202bb3a540864cba9c2cb919675a to your computer and use it in GitHub Desktop.
Find Songs given a list of words
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
['love', 'is', 'in', 'the', 'air'] | |
['mamma', 'mia'] | |
['girls', 'just', 'want', 'to', 'have', 'fun'] | |
-- | |
['love', 'is', 'in', 'the', 'air'] | |
['girls', 'just', 'want', 'to', 'have', 'fun'] | |
['love', 'is'] | |
['music'] | |
['love'] | |
['music'] | |
['love'] | |
-- | |
['we', 'are', 'the', 'champions'] | |
-- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
def print_songs_found(songs_column, clue_words): | |
for song in songs_column: | |
try: | |
songwords = [x.lower() for x in song.split()] | |
#print(songwords) | |
if all(word in clue_words for word in songwords): | |
print(songwords) | |
except: | |
pass | |
def remove_words(clue_words, removelist): | |
for rw in removelist: | |
clue_words.remove(rw) | |
def main(): | |
#Parameters | |
url = 'https://raw.githubusercontent.com/fivethirtyeight/data/master/classic-rock/classic-rock-song-list.csv' | |
url2 = 'https://raw.githubusercontent.com/walkerkq/musiclyrics/master/billboard_lyrics_1964-2015.csv' | |
url3 = 'https://www.maxtv.com.au/top-1000-greatest-songs-of-all-time-3' | |
songs = pd.read_csv(url, encoding = "ISO-8859-1") | |
songs2 = pd.read_csv(url2, encoding = "ISO-8859-1") | |
popular = pd.read_html(url3) | |
clue_words = [x.lower() for x in """ | |
We Want Champions Farewell To Mamma In Of Jambalaya | |
Gonsalves The Have Sound Girls Air Sway Que Mia Sera | |
Are Music Sera The Just Jamaica Fun Love is The Speedy | |
""".split()] | |
print(len(clue_words)) | |
list_of_song_lists = [popular[0][1], songs2['Song'], songs['Song Clean']] | |
for songs_column in list_of_song_lists: | |
print_songs_found(songs_column, clue_words) | |
print('--') | |
if __name__ == '__main__': | |
main() | |
#remove_words(clue_words, ['girls', 'just', 'want', 'to', 'have', 'fun']) | |
#remove_words(clue_words, ['love', 'is', 'in', 'the', 'air'] ) | |
#remove_words(clue_words, ['we', 'are', 'the', 'champions'] ) | |
#remove_words(clue_words, ['the', 'sound', 'of', 'music'] ) | |
#remove_words(clue_words, ['speedy', 'gonsalves'] ) | |
#remove_words(clue_words, ['que', 'sera', 'sera'] ) | |
#remove_words(clue_words, ['mamma', 'mia'] ) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment