Research Article

Python in Sentiment Analysis: A Review with a Focus on Social Media Text

Zhihao Chen*
School of Computer Science, Zhuhai College of Science and Technology, Zhuhai, Guangdong, 519040

* Corresponding author: [email protected]

Abstract

The exponential growth of user-generated content on social media platforms (e.g., Twitter, Weibo, Facebook) has created massive datasets rich in public sentiment. While sentiment analysis proves vital for understanding social trends, brand perception, and political developments, traditional methods struggle to handle the informal nature, noise, and context-dependent characteristics of social media language. This necessitates advanced computational technologies to extract meaningful insights. This paper summarizes the application of Python in social media text sentiment analysis, covering various methods supported by its NLP library (NLTK, TextBlob), machine learning/deep learning framework (TensorFlow, PyTorch), and discusses cross-platform comparative analysis and specific domain adaptation. The results indicate that Python-based models achieve high levels of accuracy. For example, the RoBERTa-BiLSTM-MHA model achieved an accuracy of 93.44%, and these models outperform conventional tools by 6–12% in terms of F1 scores. Key findings reveal cultural and platform-based disparities in sentiment expression. Specifically, Chinese social media platforms like Weibo emphasize economic sentiment, while Western platforms such as Twitter focus more on technical and ethical implications. The integration of sentiment dictionaries and multimodal data, including emojis, further enhances the robustness of these sentiment analysis models. Overall, this review underscores Python’s versatility in enabling scalable and real-time sentiment analysis, which in turn drives innovations in NLP research and practical applications.

Keywords: Python NLP; Social Media Sentiment Analysis; Deep Learning Models; Cross-Cultural Sentiment Disparities
Published: October 14, 2025
DOI: 10.54254/2755-2721/2025.LD27852
Volume: ACE Vol.191
pp. 46-51
Download PDF

References

  1. Zhang, E. K., Zhang, H. Z., Yao, J. C., & Wang, S. R. (2024). The dynamic evolution and dissemination structure of AIGC topics: A comparative analysis based on Weibo and Twitter. Journal of Xi'an Jiaotong University (Social Sciences), 44(3).
  2. Batra, H., Punn, N. S., Sonbhadra, S. K., & Agarwal, S. (2021, August). Bert-based sentiment analysis: A software engineering perspective. In International Conference on Database and Expert Systems Applications (pp. 138-148). Cham: Springer International Publishing.
  3. Pontes, E. L., & Benjannet, M. (2021, December). Contextual sentence analysis for the sentiment prediction on financial data. In 2021 IEEE International Conference on Big Data (Big Data) (pp. 4570-4577). IEEE.
  4. Wang, L. L. (2019). Research and application of Chinese text sentiment classification based on deep learning (Doctoral dissertation, Xuzhou: China University of Mining and Technology).
  5. Xue, T. (2021). A Python-based attention model for social sentiment analysis. Intelligent Computer and Applications.
  6. Chaudhari, M. (2021). Sentimental emotion analysis using Python and machine learning. International Journal of Trend in Scientific Research and Development (IJTSRD), 5(4). Available online: www.ijtsrd.com. e-ISSN: 2456-6470.
  7. Li, D. Y., Wang, Y. G., & Zhai, Q. Q. (2024). A deep learning-based method for sentiment analysis of online comments. Modeling and Simulation, 13, 5372.
  8. Xie, R. Z., & Li, Y. (2020). A text sentiment classification model based on BERT and dual-channel attention. Journal of Data Acquisition & Processing, 35(4).
  9. Joseph, T. (2024). Natural language processing (NLP) for sentiment analysis in social media. International Journal of Computing and Engineering, 6(2), 35-48.
  10. Darshan, R., & Girish, A. (2023). Twitter sentiment analysis in Python. Journal of Emerging Technologies and Innovative Research (JETIR), 10(4).