An extra racket abstraction file on top of the data-science package by Nicholas M. Van Horn specifically for tweets sentiment analysis
- Installation
- Reading Json file
- Getting tweets by source
- Timestamps by source
- Timestamp line graph by source
- Tweets classification by tweet content
- Tweets classification by image by source (Histogram)
- Sentiments by category
- Histogram plot most common words
- Classification by positive and negative words
- Negative- positive sentiment graph
- Assumption: you have racket installed
- git clone the repository https://github.com/joshmuhu/scip-sentiment-analysis.git
- install the following package raco pkg install https://github.com/n3mo/data-science.git
- run the testing.rkt
The read_json function takes in the path of the json file. It an addition to the existing read_csv function
(define tweets (read_json "temp.json"))
This function enables one to extract tweets by phone source, either android, iphone etc ........
(define android (tweet-by-source "Android" t))
retrieves data formatted in this format "~a ~b ~d ~H:~M:~S ~z ~Y"
(define android-timestamp (timestamp-by-type-new "Android" t)) Filling in the missing times to cater for 24hr (define a-time (binned-times-per-category "Android" t))
An hourly graph showing variations between the data sources passed to it a-time: takes in android time series, i-time: takes in iphone time series
(line-graph-for-hour-comparison a-time i-time)
Enables us to get tweets classified by containing image or not
(define android-pics (tweets-classification-by-image android))
The above classified tweets as containing image or not per source can be visualized using this function
(histogram-tweets-by-image-category android-pics iphone-pics "Android" "Iphone")
Get sentiments of tweets by source category. lexicon can be any 'nrc, 'bing etc
(get-sentiments-by-category data lexicon)
Drawing a histogram for the sentiments of the category passed to the function
(get-sentiments-histogram android "Tweets from Android")
Android Tweets sentiment
Iphone Tweets sentiment
using the different lexicons we can classify into positive or negative
(positive-negative-words data lexicon)
Bar graph for negative positive sentiment
(plot-negative-positive android 'bing)