Unmasking the conversation on masks: Natural language processing for topical sentiment analysis of COVID-19 Twitter discourse

Abraham Sanders, Rachael C. White, Lauren S. Severson, Rufeng Ma, Richard McQueen, Haniel C. Alcântara Paulo, Yucheng Zhang, John Erickson, Kristin P. Bennett

Abstract

In this exploratory study, we scrutinize a database of over one million tweets collected from March to July 2020 to illustrate public attitudes towards mask usage during the COVID-19 pandemic. We employ natural language processing, clustering and sentiment analysis techniques to organize tweets relating to mask-wearing into high-level themes, then relay narratives for each theme using automatic text summarization. In recent months, a body of literature has highlighted the robustness of trends in online activity as proxies for the sociological impact of COVID-19. We find that topic clustering based on mask-related Twitter data offers revealing insights into societal perceptions of COVID-19 and techniques for its prevention. We observe that the volume and polarity of mask-related tweets has greatly increased. Importantly, the analysis pipeline presented may be leveraged by the health community for qualitative assessment of public response to health intervention techniques in real time.

Introduction

Public health interventions, such as mask-wearing during a pandemic, rely heavily on public compliance. However, scientific consensus often encounters significant sociopolitical resistance. Traditional methods for gauging public opinion, such as surveys, are often too slow to capture the nuance of organic, real-time discourse. This research from Rensselaer Polytechnic Institute (RPI) addresses this gap by developing a systematic NLP pipeline to characterize public attitudes toward face masks during the first half of 2020. The study aims to identify the core themes of the mask-wearing discourse, track sentiment changes over time, and automate narrative generation for real-time public health monitoring.

Methodology

The researchers developed a multi-stage NLP pipeline to transform raw social media data into high-level thematic narratives:

  1. Data Collection & Filtering: From an initial pool of 189 million COVID-related tweets, approximately 1 million tweets specifically mentioning masks were extracted using an Elasticsearch keyword-based index.
  2. Embeddings: To capture semantic meaning, Google’s Universal Sentence Encoder (USE) transformed each tweet into a 512-dimensional vector.
  3. Sentiment Analysis: The VADER algorithm, optimized for social media lexicon (including emojis and slang), assigned polarity scores to each tweet.
  4. Hierarchical Clustering: K-means clustering established a two-level hierarchy consisting of 15 high-level themes, each containing 15 specific topics. t-SNE was employed to project these high-dimensional clusters into 2D maps for visualization.
  5. Labeling & Summarization: KL-divergence identified distinctive keywords for each cluster. Finally, DistilBART, an abstractive summarization model fine-tuned on the xsum dataset, generated concise summaries of representative tweets.
Overview of the tweet embedding, sentiment scoring, and hierarchical clustering pipeline.

Results and Key Insights

The analysis revealed several critical trends in the global conversation surrounding face masks:

  • Volume and Sentiment Shifts: Mask-related tweet volume and polarity increased dramatically starting in mid-June 2020. Statistical analysis (ANOVA and Dunnett’s tests) confirmed that mean sentiment scores from April through July were significantly more negative than in March ($p < 0.001$).
  • The "Trump" Effect: Cluster 1, centered on Donald Trump, emerged as the most negative cluster, suggesting that the mask debate became a proxy for political identity rather than just a health concern.
  • Complex Sentiment: Negative sentiment did not always equate to anti-mask views. For instance, Cluster 2 ("vaccine/flu/stop") showed negative polarity because users were expressing frustration with non-compliance or discussing illness and death.
  • Increasing Polarization: Using Sarle’s Bimodality Coefficient, the researchers found that 13 out of 15 clusters showed a statistically significant trend toward increased divisiveness over the five-month period.
Tweet counts by sentiment for each of the 15 primary clusters, alongside their identifying keywords.

Discussion and Limitations

While the pipeline offers powerful insights, several limitations remain. VADER struggles with sarcasm, a prevalent feature of political Twitter discourse. Additionally, as a generative model, DistilBART can occasionally produce "hallucinations" or factually inaccurate summaries if the input data is noisy. Geographic analysis was also limited by the fact that less than 1% of users share precise location data, making regional analysis difficult without introducing significant bias.

Conclusion

This study demonstrates that topic clustering and sentiment analysis of Twitter data can provide revealing insights into societal perceptions of health interventions. The proposed pipeline offers a framework for the health community to qualitatively assess public response to health strategies in real time, allowing for more agile and informed messaging.

Summary updated

Abstract

Abstract In this exploratory study, we scrutinize a database of over one million tweets collected from March to July 2020 to illustrate public attitudes towards mask usage during the COVID-19 pandemic. We employ natural language processing, clustering and sentiment analysis techniques to organize tweets relating to mask-wearing into high-level themes, then relay narratives for each theme using automatic text summarization. In recent months, a body of literature has highlighted the robustness of trends in online activity as proxies for the sociological impact of COVID-19. We find that topic clustering based on mask-related Twitter data offers revealing insights into societal perceptions of COVID-19 and techniques for its prevention. We observe that the volume and polarity of mask-related tweets has greatly increased. Importantly, the analysis pipeline presented may be leveraged by the health community for qualitative assessment of public response to health intervention techniques in real time.
BibTeX
@inproceedings{sanders2021unmasking,
  author = {Abraham Sanders and Rachael C. White and Lauren S. Severson and Rufeng Ma and Richard McQueen and Haniel C. Alcântara Paulo and Yucheng Zhang and John Erickson and Kristin P. Bennett},
  title = {{Unmasking the conversation on masks: Natural language processing for topical sentiment analysis of COVID-19 Twitter discourse}},
  booktitle = {PubMed},
  year = {2021},
}
Figure