def test_correct_url_output_lyrics1(): """ Test url generation for lyrics """ actual = 'http://api.musixmatch.com/ws/1.1/track.search?q_lyrics=hello-somewhere&apikey=2224fd10c87468942ca6a90f01294452' sf = lyric_matching.song_finder(["hello", "somewhere"]) sf.url_constructer_for_lyrics() assert actual == sf.lyric_api_url
def test_correct_url_output_chart3(): """ Test url generation for chart songs """ actual = 'http://api.musixmatch.com/ws/1.1/chart.tracks.get?page_size=1&country=uk&apikey=2224fd10c87468942ca6a90f01294452' sf = lyric_matching.song_finder(["what", "somewhere"]) sf.url_constructer_for_chart_songs("uk") assert actual == sf.chart_url
def test_subset_functions3(): """ Test the subset making function for keywords""" s = set([1,2,3]) l = [set([1, 2, 3])] sf = lyric_matching.song_finder(["romeo", "somewhere"]) subsets = sf.find_all_subsets_of_keywords_of_size_n(s, 3) assert subsets == l
def main(): """ Initialize the subscription handler and determine the list of users to whom we need to send recommendations """ subscription_handler = text_message.subscription_handler() subscription_handler.handle_subscriptions() user_recipient_list = subscription_handler.recipient_list for user in user_recipient_list: """ Initialize Twitter data object and get tweets object """ td = twitter_data.twitter_data(user.twitter_username) #td = twitter_data.twitter_data('testuser242') tweets = td.twitter_data_wrapper() """ Initialize part of speech extracter object """ pos_extracter = keyword_extracting_algorithms.part_of_speech_extracter() """ Obtain keywords from recent tweets by extracting only the nouns and verbs """ keywords = pos_extracter.parse_nouns_and_verbs(tweets) keyword_list = list(keywords.keys()) """ Obtain a song that matches the keywords previously generated """ song_finder = lyric_matching.song_finder(keyword_list) song_finder.find_song() song_url = song_finder.song_url song_artist = song_finder.song_artist song_title = song_finder.song_title """ Format the text message to be sent that includes song information """ message_formatter = text_message.message_formatter(song_artist, song_title, song_url) message_author_title_url = message_formatter.format_message_author_title_url() message_url = message_formatter.format_message_url() """ Actually send the text message to the recipient""" text_messager= text_message.text_messager(user.phone_number) text_messager.send_message(message_author_title_url)
def main(): """ Initialize the subscription handler and determine the list of users to whom we need to send recommendations """ subscription_handler = text_message.subscription_handler() subscription_handler.handle_subscriptions() user_recipient_list = subscription_handler.recipient_list for user in user_recipient_list: """ Initialize Twitter data object and get tweets object """ td = twitter_data.twitter_data(user.twitter_username) #td = twitter_data.twitter_data('testuser242') tweets = td.twitter_data_wrapper() """ Initialize part of speech extracter object """ pos_extracter = keyword_extracting_algorithms.part_of_speech_extracter( ) """ Obtain keywords from recent tweets by extracting only the nouns and verbs """ keywords = pos_extracter.parse_nouns_and_verbs(tweets) keyword_list = list(keywords.keys()) """ Obtain a song that matches the keywords previously generated """ song_finder = lyric_matching.song_finder(keyword_list) song_finder.find_song() song_url = song_finder.song_url song_artist = song_finder.song_artist song_title = song_finder.song_title """ Format the text message to be sent that includes song information """ message_formatter = text_message.message_formatter( song_artist, song_title, song_url) message_author_title_url = message_formatter.format_message_author_title_url( ) message_url = message_formatter.format_message_url() """ Actually send the text message to the recipient""" text_messager = text_message.text_messager(user.phone_number) text_messager.send_message(message_author_title_url)
def test_determine_if_valid_results_exist(): """ Test if there is a need to determine a popular song to recommend """ sf = lyric_matching.song_finder(["romeo", "somewhere"]) assert sf.determine_if_valid_results_exist() == False