Sentiment Analysis for Monitoring Public Opinion on Social Media about Public Services
Abstract
This paper presents a system for monitoring the public perspective on public services in Brazil, based on sentiment analysis of messages from the social network Twitter. The methodology involves four steps: data collection, pre-processing, analysis and visualization. Data collection is performed by a Python scraper, capable of bypassing the limitations of official APIs and extracting public tweets related to topics such as education, health and transportation. The data is structured in JSON and stored in the NoSQL MongoDB database. Pre-processing applies Natural Language Processing methods for text cleaning and normalization. Sentiment analysis is performed with the pre-trained lipaoMai/BERT model, which classifies texts as positive, negative or neutral. The results are displayed in an interactive dashboard developed with Angular and PrimeNG, powered by a RESTful API in Java Spring Boot. The platform highlights the potential of using Artificial Intelligence and text mining techniques in public management, by offering strategic support for decision-making based on up-to-date data that is representative of society's opinion.
References
ALVAREZ-MELIS, D.; GITTENS, A.; JAAKKOLA, T. Public opinion mining using social media in government decision-making. arXiv, 2023. Disponível em: [link]. Acesso em: 20 maio 2025.
ALVES, J. P. R.; MENEZES, M. O. de. A análise de sentimentos e emoções de mensagens de redes sociais envolvendo serviços de entrega de alimentos. 2024. Disponível em: [link]. Acesso em: 19 maio 2025.
ANGULAR. Angular: documentação oficial. 2025. Disponível em: [link]. Acesso em: 20 maio 2025.
BISHOP, C. M. Pattern recognition and machine learning. New York: Springer, 2006.
BORGOGNO, O.; CASALINI, A.; IACOMINI, E. Digital platforms and social listening: Using Twitter data for public interest analysis. Journal of Digital Government Research, v. 11, n. 1, p. 23–40, 2024.
CAMBRIA, E.; WHITE, B. Jumping NLP curves: a review of natural language processing research. IEEE Computational Intelligence Magazine, v. 9, n. 2, p. 48–57, 2014.
CARDOSO, Oscar. O Web Scraping Viola a Proteção de Dados Pessoais? | Jusbrasil. Disponível em: [link]. Acesso em: 3 jun. 2025.
CORREA, C. G. F. de O. Mineração de textos: análise de sentimentos de tweets sobre o Projeto de Lei n° 2630/2020. 2024. 61 f. Trabalho de Conclusão de Curso (Graduação em Gestão da Informação) – Universidade Federal de Uberlândia, Uberlândia, 2024. Disponível em: [link]. Acesso em: 19 maio 2025.
DEVLIN, Jacob et al. BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding. arXiv preprint arXiv:1810.04805, 2018. Disponível em: [link]. Acesso em: 5 ago. 2025.
ECMA INTERNATIONAL. ECMAScript Language Specification (JavaScript). 2023. Disponível em: [link]. Acesso em: 20 maio 2025.
FELDMAN, R.; SANGER, J. The text mining handbook: advanced approaches in analyzing unstructured data. Cambridge: Cambridge University Press, 2007.
GÉRON, A. Hands-on machine learning with Scikit-Learn, Keras, and TensorFlow. 2. ed. Sebastopol: O’Reilly Media, 2019.
HOTHO, A.; NÜRNBERGER, A.; PAAß, G. A brief survey of text mining. LDV Forum, v. 20, n. 1, p. 19–62, 2005.
HUGGING FACE. BERT sentiment analysis portuguese. Hugging Face, 2023. Disponível em: [link]. Acesso em: 20 maio 2025.
JURAFSKY, D.; MARTIN, J. H. Speech and language processing: an introduction to natural language processing, computational linguistics, and speech recognition. 3. ed. [Online draft], 2023. Disponível em: [link]. Acesso em: 19 maio 2025.
KAPLAN, J. Web Scraping with Python: Collecting Data from the Modern Web. 2. ed. O’Reilly Media, 2021.
KREPS, J. et al. MongoDB for Big Data and Real-Time Analytics. Data Engineering Journal, v. 9, n. 3, p. 45–62, 2023.
LIU, B. Sentiment analysis: mining opinions, sentiments, and emotions. 2. ed. Cambridge: Cambridge University Press, 2020.
LOPES, M. F. M. Análise de sentimentos em redes sociais durante a temporada 2022 da Fórmula 1: um estudo utilizando processamento de linguagem natural no Twitter. Repositório Institucional da UTFPR, 2023. Disponível em: [link]. Acesso em: 19 maio 2025.
MITCHELL, T. M. Machine learning. New York: McGraw-Hill, 1997.
MONGODB INC. MongoDB Documentation. 2025. Disponível em: [link]. Acesso em: 20 maio 2025.
MORIN, D.; BOURDEAU, D. Data Science and Web Scraping Using Python. Springer, 2020.
PRIMETEK INFORMATICS. PrimeNG v19 – UI components for Angular. 2025. Disponível em: [link]. Acesso em: 20 maio 2025.
PUPPETEER. Puppeteer Documentation. 2025. Disponível em: [link]. Acesso em: 20 maio 2025.
PYTHON SOFTWARE FOUNDATION. Python Language Reference, versão 3.11. 2023. Disponível em: [link]. Acesso em: 20 maio 2025.
REQUISITOS. Requests: HTTP for Humans. 2025. Disponível em: [link]. Acesso em: 20 maio 2025.
RICHARDSON, L. BeautifulSoup Documentation. 2025. Disponível em: [link]. Acesso em: 20 maio 2025.
ROKOSZ, K.; BIEŃ, A. Sentiment analysis of digital public discourse as support for social policy. Information Systems and e-Business Management, v. 23, n. 1, p. 55–73, 2025.
SELENIUM. Selenium Documentation. 2025. Disponível em: [link]. Acesso em: 20 maio 2025.
SILVA, H. et al. Sentiment Analysis of Tweets Related to SUS Before and During COVID-19 pandemic. IEEE Latin America Transactions, v. 20, n. 1, p. 6–13, 2021. Disponível em: [link]. Acesso em: 19 maio 2025.
SOUZA, F.; LIMA, F.; COUTINHO, T. Avaliação de modelos BERT para análise de sentimentos em português. Revista Brasileira de Computação Aplicada, v. 15, n. 2, p. 44–56, 2023.
TEXTBLOB. TextBlob: simplified text processing [software]. [S. l.], 2013. Disponível em: [link]. Acesso em: 4 ago. 2025.
TWITTER. Plataforma de microblog usada como fonte de dados para análise de sentimentos. Twitter, 2025. Disponível em: [link]. Acesso em: 20 maio 2025.
VMWARE. Spring Boot Documentation. 2025. Disponível em: [link]. Acesso em: 20 maio 2025.
ZHANG, Y.; GUI, L.; CAMBRIA, E. Sentiment analysis: a survey. Information Fusion, v. 91, p. 202–240, 2022. DOI: 10.1016/j.inffus.2022.01.004.
