Twitter sentiment analysis from the Christchurch Terror attack
This story, adapted for Medium, was originally submitted for paper COMP811 — Research Methods (later renamed to ENGE817 — Research Methods) as part of the Master of Information Security and Digital Forensics course at the Auckland University of Technology (AUT).
A special thanks to Dr. Farhaan Mirza and Dr. Herman Wandabwa for their guidance. Dr. Farhaan is passionate about Data and teaching the nuances of academic research to students. He has some essential research tips on his personal website. Dr Herman has recently completed his PhD and likes to write about his country of birth, Kenya and also his newly adopted home of New Zealand.
Introduction
This story gauges public opinion to New Zealand’s Prime Minister response, in the aftermath of the Christchurch terror attack of March 2019. A sentiment analysis of Twitter data from the public’s response to Jacinda Ardern’s tweets was performed. A measure of public sentiment gives a direct indication of how well the Prime Minister performed in leading the country through this difficult time. There has been no similar analysis conducted in the aftermath of the attack. Most importantly the measure of effectiveness of Jacinda’s response, can set an example for Governments around the world on how to structure their post-disaster response and policies.
The events which unfolded in Christchurch on the 15th of March 2019, have been described as one the deadliest attacks in the history of New Zealand. This single event led to an elaborate Government response which included information censorship, introducing new gun control laws and an extensive gun buy-back program. The immediate official response was recorded in the form of two tweets on the day from Prime Minister Jacinda Ardern.This was followed by Twitter activity in response to the tweets. RapidMiner Studio and MeaningCloud API were used to perform sentiment analysis.
Performing Sentiment Analysis
Sentiment analysis was performed over four phases
Phase 1 — Twitter Data Collection
A manual inspection was conducted of Jacinda Ardern’s Twitter feed and important information was captured, like her username, the tweets made on the day of the attack.
Jacinda tweeted twice on the day. From these two tweets and its replies, a list of hashtags was noted. From this, a search criterion was finalized. Tweets containing the following username and hashtags were collected.
@jacindaardern #JacindaArdern
#NZMosqueShooting #ChristchurchTerrorAttack
#NZterrorattack #ChristchurchMosque
#NewZealandTerroristAttack #ChristchurchMosqueAttack
#NZMosque #ChristchurchTERRORISTattack
#newzealandterrorattack #Christchurch
#NewZealandMosqueShooting #ChChMosque
#NewZealandShooting #ChChShooting
#newzealandmosqueattack #KiaKaha
#NewZealandMosque #TheyAreUs
Tweets were collected between the dates of 15th March 2019 to 15th August 2019 utilizing a bespoke Python script. The script assisted in downloading tweets based on a date range and consisting of specific hashtags. A total of 13270 tweets were collected.
Phase 2 — Removal of multi-language tweets
MeaningCloud API documentation suggests that non-English language tweets are flagged as having sentiment “None”. If the collected data set has a large number of non-English tweets, the corresponding flagging of these tweets as “None” distorts the results of sentiment analysis. The Multi-language tweets are removed by identifying non-English characters. This was done by importing the CSV containing the Tweet data into Excel. An Excel formula was then created to highlight the tweets which contain characters other than those found in English.
A total of 2465 tweets were removed leaving behind 10805 English tweets as candidates for sentiment analysis. The 2465, non-English tweets, contained a small minority of foreign language tweets written in the Latin script and also tweets consisting of just videos and photos. These were removed after manual inspection of the data set.
Phase 3 — Sentiment analysis
The MeaningCloud API performs sentiment analysis based on a text input provided (i.e. the tweets collected). MeaningCloud utilizes Natural Language Processing (NLP) techniques to examine the sentences present in the text and a relation between them is assessed. A polarity value of the text is calculated based on the different sentences in the text. There are six different polarity values. The polarity values reflect the sentiment of the tweets.
In RapidMiner a process pipeline was created consisting of the below three operators.
Read CSV — reads the CSV file containing tweet data.
Sentiment Analysis — runs the CSV file through MeaningCloud.
Write CSV — writes the output to a result file.
Results and analysis
The fourth and final phase of sentiment analysis was the results and corresponding analysis.
Tweet volumes
The incident in Christchurch unfolded on 15th of March 2019. Tweet data was collected between the 15th of March to 15th of August. After removing the non-English tweets, 10805 tweets were in scope of the study. Analysis of the collected results show the largest number of tweets were posted in the month of March. The tweet volume drops considerably as time elapses.
Tweet polarity
The MeaningCloud API can return six polarity values. These values are Very Positive (P+), Positive (P), Neutral, None (No Polarity), Negative (N), Very Negative (N+). One of these six polarity values are assigned to each tweet.
Some examples of the tweets across each of the polarity values are
Out of the total number of tweets, 9% of the public response was Very Positive followed by 37% of Positive. This gives us a total of 46% sentiment as positive during the five months from March to August. During this time 8% of the public sentiment expressed was Very Negative and 23% was Negative. This gives us a combined negative opinion by 31% of the responses to Jacinda’s tweets. 10% of the responses came out to be Neutral and 13% as None. Thus 23% of the responses were neither negative or positive.
Monthly trends
The monthly spread of tweets is as below.
To evaluate the sentiment trend from March to August the sum of the Positive, Negative polarities and a combination of the Neutral and None polarities is calculated. In each month if the net Positive polarity is greater than the Negative polarity, the trend is said to be positive otherwise negative.
Summary
Twitter data was collected from 15th March to 15th August. The data was then pre-processed to remove any non-English tweets and tweets which could not be processed. A sentiment analysis using the MiningCloud API was performed. The results of the sentiment analysis showed that 46% of the public response was positive compared to a fully negative response figure of 31%. Out of these responses 23% of the responses were of Neutral polarity and of polarity None.This study can conclude with some level of confidence that the public response to Jacinda Ardern’s tweets has been Positive.
Limitations and future work
Sentiment analysis as part of this paper was not performed as full-fledged research project. It was more curiosity and the necessity to draft up a very short and simple mini research project. Due to this, only a single social media source Twitter was considered for just the first five months, giving me enough time to submit the paper as part of my studies in 2019. It should therefore come as no surprise that the data volumes were abysmally low.
For anyone interested in doing more analysis, I would highly recommend to consider additional richer sources of social media maybe Facebook or Reddit with an expanded timeline. This will ensure that analysis is performed over a larger dataset possibly giving more meaningful insights.
Lastly, I am not a data scientist and none of the advanced data analysis methods were used.