How do people feel about the recent Lee Hsien Loong issue? We used code to find out

Photo credit: The Straits Times.
It was an eventful morning in Singapore yesterday.
Here are just some of the headlines:
- Lee Wei Ling, Lee Hsien Yang issue statement to say they have ‘lost confidence’ in PM Lee Hsien Loong
- Lee Hsien Yang wants to leave Singapore, publishes open letter with sister to criticize PM Lee
- PM Lee Hsien Loong ‘saddened’ by statement from siblings Lee Wei Ling and Lee Hsien Yang
But what do the people think?
We tried to gauge the public’s response to these statements based on Facebook comments. To do this, we used:
- Python 3
- The Facebook Graph API to download comments from Facebook
- The Google Cloud Natural Language API to perform sentiment analysis
First, we downloaded the comments from a Facebook post using the Facebook Graph API. For this project, we used this post on Lee Hsien Loong’s (LHL) Facebook page responding to his siblings’ statements.
The approach we used can be easily adapted to any post on a public Facebook page, like Lee Hsien Yang’s original post, for example.
We then used the Google Cloud Natural Language API to classify the comments on these posts as either positive, neutral, or negative and calculated the proportion of these comments on each of these posts.
Important note
Facebook is by no means a source of objective views. It is extremely likely that the comments we found on these posts are biased to some degree.
There is also the possibility of moderation, further reducing the objectivity of our findings. This article should be taken purely as an exercise in using the Facebook Graph API and Google Cloud Natural Language API, and not to draw any conclusions about Singapore’s political situation.
Getting started
Setting up Python 3
I won’t discuss here how to download and install Python 3. You can consult the Python documentation here. But just to check your Python version, open your Python prompt and inspect its output. You should see something similar to:
Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>>
Downloading Facebook comments
Analyzing the comment sentiments
Conclusion
Stay updated on the go with our mobile app.
Get latest insights with smoother, more personalized experience through TIA mobile app.







