hamemuh / UKelections2017

Sentiment analysis to forecast the outcome of the UK 2017 snap election.
0 stars 1 forks source link

Plot time series for sentiment analysis #20

Closed hamemuh closed 7 years ago

hamemuh commented 7 years ago

I have used the code that Jordon shared to start ingesting tweets on my own computer at home and work on the following:

  1. Get the month, day and hours as separate fields in the database
  2. Plot this against polarity for now, then use the final sentiment measure when it becomes available
hamemuh commented 7 years ago

Update: Can connect to mongo and manipulate date/time to get required fields, using string manipulation.

Python Code:

connection = pymongo.MongoClient() db = connection.twitter_db tweet = db.test.find_one({},{text:1, ploarity:1, subjectivity:1, created_at:1}) json.loads(tweet) l = tweet['created_at'].split(' ') # gives all datetime info in a list l[3] # can slice this to get month, day etc

hamemuh commented 7 years ago

Have created a program to put tweets from mongo into a dataframe. It is in the graphTest.py file.