Sentiment Analysis of Public Discourse on Pakistan's Political Parties: A Comparative Study Using VADER and TextBlob Algorithms on Twitter Data
DOI:
https://doi.org/10.63913/jds.v1i2.9Keywords:
Sentiment Analysis, Twitter, Political Discourse, VADER, TextblobAbstract
This study explores public sentiment toward two of Pakistan's major political parties—Pakistan Peoples Party (PPP) and Pakistan Tehreek-e-Insaf (PTI)—by analyzing Twitter discourse using sentiment analysis techniques. A dataset of 1,184 tweets related to the trending topic "PPP and PTI" was collected and processed to examine how these parties are perceived online. Two lexicon-based sentiment analysis algorithms, VADER and TextBlob, were applied to the tweet content to compute sentiment polarity scores and categorize each tweet as positive, neutral, or negative. Exploratory Data Analysis (EDA) was conducted to assess engagement metrics, tweet length distribution, and user activity patterns. A keyword-based method was used to assign party focus to tweets, enabling comparative sentiment analysis between PPP and PTI. The results indicate that PPP was more frequently mentioned than PTI, comprising over 93% of the classified tweets. Both VADER and TextBlob showed moderate agreement in sentiment classification, with a Pearson correlation coefficient of 0.5761 and a 66.39% match in sentiment labels. Temporal analysis revealed fluctuations in sentiment scores, often corresponding to real-world political events, such as alliance discussions or leadership announcements. Tweets with higher engagement—measured by likes, retweets, replies, and views—tended to exhibit stronger sentiment polarity. Top positive and negative words were also identified to interpret linguistic patterns behind sentiment classification. This study demonstrates the potential of sentiment analysis as a tool for political communication, campaign strategy, and public opinion monitoring. However, limitations such as platform bias and data parsing issues warrant cautious interpretation of the results. Future research may benefit from incorporating multi-platform data and advanced NLP models to enhance reliability and granularity. The findings contribute to the growing field of digital society studies by offering a data-driven lens into political discourse on social media.