def test_spell_check4(): """ Test spell checker for word off by 0 edits """ word = "correct" pos_extracter = keyword_extracting_algorithms.part_of_speech_extracter() correction = pos_extracter.correct_word(word) assert "correct" == correction
def test_spell_check3(): """ Test spell checker for word off by more than 2 edits """ word = "skdjfaksldfj" pos_extracter = keyword_extracting_algorithms.part_of_speech_extracter() correction = pos_extracter.correct_word(word) assert "skdjfaksldfj" == correction
def test_lemmatization3(): """ Test the lemmatization function """ word = "run" pos_extracter = keyword_extracting_algorithms.part_of_speech_extracter() base_morpheme = pos_extracter.lemmatization(word) assert "run" == base_morpheme
def test_parse_nouns_and_verbs5(): """ Test that the part of speech extracter is extracting only nouns and verbs """ dictionary = set_up_parse_nouns_and_verbs(["twitter", "run"]) pos_extracter = keyword_extracting_algorithms.part_of_speech_extracter() assert (dictionary == pos_extracter.parse_nouns_and_verbs( ["twitter", "run"]))
def test_parse_nouns_and_verbs4(): """ Test that the part of speech extracter is extracting only nouns and verbs """ dictionary = set_up_parse_nouns_and_verbs(["walking", "yellow"]) pos_extracter = keyword_extracting_algorithms.part_of_speech_extracter() assert (dictionary != pos_extracter.parse_nouns_and_verbs( ["yellow", "wallking", "he"]))
def get_tweets(self, api): """ Get a user's most recent tweets @param api : the api object returned by the authentication method @return list of tweets """ pos_extracter = keyword_extracting_algorithms.part_of_speech_extracter() user = api.get_user(self.username) public_tweets = api.home_timeline() my_tweets = [] for tweet in public_tweets: my_tweets.append(tweet.text) all_tweets = [str(x) for x in my_tweets] return all_tweets[0:self.num_recent_tweets]
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)