assignment, you will conductsentiment analysis on Twitter. To do this, you first need todownload some recent tweets using the Twitter API, and then use two different methods to extract the sentiment...


assignment, you will conductsentiment analysis on Twitter. To do this, you first need todownload some recent tweets using the Twitter API, and then use two different methods to extract the sentiment of a tweet.


Here are the steps required to download tweets using the Twitter API:


1- Create a new applicationon https://apps.twitter.com/ and obtain Customer_key, Customer_secret, Access_token, Access_token_secret for downloading tweets.


2- Use the belowsample script to download the tweets regarding your input query. For instance, suppose that the following script is stored as print_tweets.py. You canrun the script like
print_tweets.py "Donald Trump"to extract and print a sample of tweets about Donald Trump.


3-After downloading the tweets, you are requiredto run sentiment analysis on these tweetsusing one of the existing libraries and provide your insight about the collected data.Some choices you could make (with sample code)are listed below:



Extra Credit: Use Pointwise Mutual Information (PMI) method explained in the lectureto calculate the sentiment of the tweets and compare the result with the result of part 3.


Hint: I would strongly suggest to read this great blog post before working on the extra points section:



https://marcobonzanini.com/2015/03/02/mining-twitter-data-with-python-part-1/(Links to an external site.)Links to an external site.


Please submit a zip file named using thefollowing format (HW3-FirstName-LastName.zip) containing:


- Your report in PDF or Word (minimum 2 pages;11 point font, 1 inch margins on all sides).


-Your Jupyter notebook or Python script


- Your collected tweet dataset.


import tweepy

def get_tweets(api, input_query):

for tweet in tweepy.Cursor(api.search, q=input_query, lang="en").items():

yield tweet


if __name__ == "__version__":

input_query = sys.argv[1]



access_token = "REPLACE_YOUR_KEY_HERE"

access_token_secret = "REPLACE_YOUR_KEY_HERE"

consumer_key = "REPLACE_YOUR_KEY_HERE"

consumer_secret = "REPLACE_YOUR_KEY_HERE"


auth = tweepy.OAuthHandler(consumer_key, consumer_secret)

auth.set_access_token(access_token, access_token_secret)

api = tweepy.API(auth)


tweets = get_tweets(api, input_query)

for tweet in tweets:

print(tweet.text)


Rubric


HW3 Rubric HW3 Rubric

































CriteriaRatingsPts

This criterion is linked to a Learning Outcome Creating your account for Twitter API


10.0 pts


This criterion is linked to a Learning Outcome Downloading and Parsing the tweets


25.0 pts


This criterion is linked to a Learning Outcome Sentiment Analysis using an existing library


40.0 pts


This criterion is linked to a Learning Outcome Discussion and Comparison of results


25.0 pts


Total Points: 100.0
Mar 17, 2020
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here