Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The project goal is to collect and manage data collected from Twitter. You will

ID: 3590701 • Letter: T

Question

The project goal is to collect and manage data collected from Twitter. You will build your project according to the following requirements:

The first step is to get familiar with Twitter API and how to interact with it from your own Java application. Here are some examples. You will use the Search for Tweets functionality of the API.

It requires a simple user interface from which the user can specify the keyword query. The user interface has three parts. One part is the query part that includes at least a text box, a SUBMIT button, and a SAVE button. One other part of the window will display the results (tweets) returned in response to a user query. The third part will display some aggregate results, which will be described below.

When the user clicks on SUBMIT, you will take the keyword query and pass it to the Twitter API. Get all the results and display them to the user.

The user may decide to keep the data that was returned in response to the query and she will press the button SAVE. You have to take the set of tweets and store them in a data structure according to the following requirements.

Create a class structure to manage tweets. The class will store pieces of data such as text, time, user.

For each tweet, determine if the tweet contains a hashtag. If it does, extract the hashtag. Use the hashtag to index the tweets.

Using the data structures covered so far, i.e., ArrayList, Vector, and SingleLinkedList, keep track of all the tweets that contain a certain hashtag. Note that a tweet may have more than a hashtag, hence, it may belong to multiple lists of tweets.

For each hashtag, keep a count of the number of tweets that contain it.

In the third part of your GUI show the top-10 hashtags according to their count. The list updates after each click of the SAVE button.

Implementation requirements:

use Java ArrayList and LinkedList data structures to keep track of the data handled by your program.
NOTE: the use of other data structures other than these two will be penalized.

Explanation / Answer

the code has so far

#Import the necessary methods from tweepy library
from tweepy.streaming import StreamListener
from tweepy import OAuthHandler
from tweepy import Stream

#Variables that contains the user credentials to access Twitter API
access_token = "ENTER YOUR ACCESS TOKEN"
access_token_secret = "ENTER YOUR ACCESS TOKEN SECRET"
consumer_key = "ENTER YOUR API KEY"
consumer_secret = "ENTER YOUR API SECRET"


#This is a basic listener that just prints received tweets to stdout.
class StdOutListener(StreamListener):

def on_data(self, data):
print data
return True

def on_error(self, status):
print status


if __name__ == '__main__':

#This handles Twitter authetification and the connection to Twitter Streaming API
l = StdOutListener()
auth = OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
stream = Stream(auth, l)

#This line filter Twitter Streams to capture data by the keywords: 'python', 'javascript', 'ruby'
stream.filter(track=['python', 'javascript', 'ruby'])