Skip to main content

Exploration, Sentiment Analysis, Topic Modeling, and Visualization of Moroccan Twitter Data

  • Conference paper
  • First Online:
Advanced Intelligent Systems for Sustainable Development (AI2SD’2020) (AI2SD 2020)

Abstract

Twitter is used more and more by Internet users as a means of expressing their opinions. In this research work, we are interested in analyzing the tweets published by Moroccan users to generate some useful statistics, identify different sentiments, and extract then visualize predominant topics. First, we collected 52 939 tweets using Twitter API and python language and stored them in MongoDB database. Stored tweets were preprocessed by applying natural language processing techniques (NLP) using the NLTK library. Then, we performed sentiment analysis, which classifies the polarity of Twitter comments into negative, positive, and neutral categories. Finally, we applied topic modeling over the tweets using Latent Dirichlet Allocation (LDA) and visualize the most discussed topics with LDAvis.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 189.00
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 249.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Similar content being viewed by others

References

  1. Twitter Usage Statistics - Internet Live Stats. https://www.internetlivestats.com/twitter-statistics/ (consulté le févr. 19, 2020)

  2. DataReportal – Global Digital Insights . [En ligne]. Disponible sur: https://datareportal.com [Consulté le: le mars 25, 2020]

  3. Tripathi, P., Vishwakarma, S.K.R., Lala, A.: Sentiment analysis of english tweets using rapid miner. In: 2015 International Conference on Computational Intelligence and Communication Networks (CICN), Jabalpur, India, pp. 668–672 (2015). https://doi.org/10.1109/CICN.2015.137

  4. Al-Thubaity, A., Alqahtani, Q., Aljandal, A.: Sentiment lexicon for sentiment analysis of Saudi dialect tweets. Procedia Comput. Sci. 142, 301–307 (2018). https://doi.org/10.1016/j.procs.2018.10.494

  5. Wang, X., Yu, Y., Lin, L.: Tweeting the united nations climate change conference in Paris (COP21): an analysis of a social network and factors determining the network influence. Online Soc. Netw. Media, 15, 100059 (2020). https://doi.org/10.1016/j.osnem.2019.100059

  6. Cvetojevic, S., Hochmair, H.H.: Analyzing the spread of tweets in response to Paris attacks. Comput. Environ. Urban Syst. 71, 14–26 (2018). https://doi.org/10.1016/j.compenvurbsys.2018.03.010

  7. Grimaldi, D., Cely, J.D., Arboleda, H.: Inferring the votes in a new political landscape: the case of the 2019 Spanish Presidential elections. J. Big Data 7(1), 1–19 (2020). https://doi.org/10.1186/s40537-020-00334-5

    Article  Google Scholar 

  8. Onyenwe, I., Nwagbo, S., Mbeledogu, N., Onyedinma, E.: The impact of political party/candidate on the election results from a sentiment analysis perspective using #AnambraDecides2017 tweets. Soc. Netw. Anal. Min. 10(1), 1–17 (2020). https://doi.org/10.1007/s13278-020-00667-2

    Article  Google Scholar 

  9. O’Callaghan, D., Greene, D., Carthy, J., Cunningham, P.: An analysis of the coherence of descriptors in topic modeling. Expert Syst. Appl. 42(13), 5645–5657, août (2015). https://doi.org/10.1016/j.eswa.2015.02.055

  10. Ramage, D., Hall, D., Nallapati, R., Manning, C.D.: Labeled LDA: a supervised topic model for credit attribution in multi-labeled corpora. In: Proceedings of the 2009 Conference on Empirical Methods in Natural Language Processing Volume 1 - EMNLP 2009, Singapore, vol. 1, p. 248, (2009). https://doi.org/10.3115/1699510.1699543

  11. Zhang, L., Hall, M., Bastola, D.: Utilizing Twitter data for analysis of chemotherapy, Int. J. Med. Inf. 120, 92–100 (2018). https://doi.org/10.1016/j.ijmedinf.2018.10.002

  12. Yoosefi Nejad, M., Delghandi, M.S., Bali, A.O., Hosseinzadeh, M.: Using twitter to raise the profile of childhood cancer awareness month. Netw. Model. Anal. Health Inform. Bioinform. 9(1), 1–5 (2019). https://doi.org/10.1007/s13721-019-0206-4

    Article  Google Scholar 

  13. Hajjem, M., Latiri, C.: Combining IR and LDA topic modeling for filtering microblogs. Procedia Comput. Sci. 112, 761–770 (2017). https://doi.org/10.1016/j.procs.2017.08.166

  14. Hagen, L.: Content analysis of e-petitions with topic modeling: how to train and evaluate LDA models?. Inf. Process. Manag. 54(6) 1292–1307 (2018). https://doi.org/10.1016/j.ipm.2018.05.006

  15. Tweepy. [En ligne]. Disponible sur: https://www.tweepy.org/. [Consulté le: 25-nov-2019]

  16. The most popular database for modern apps, MongoDB. [En ligne]. Disponible sur: https://www.mongodb.com. [Consulté le: 25-nov-2019]

  17. Siddharth, S., Darsini, R., Sujithra, D.M.: Sentiment analysis on twitter data using machine learning algorithms in python , 15

    Google Scholar 

  18. seaborn: statistical data visualization — seaborn 0.10.0 documentation . [En ligne]. Disponible sur: https://seaborn.pydata.org/. [Consulté le: 12-févr-2020]

  19. Matplotlib: Python plotting — Matplotlib 3.1.3 documentation. [En ligne]. Disponible sur: https://matplotlib.org/. [Consulté le: 12-févr-2020]

  20. Blei, D.M.: Latent Dirichlet Allocation, p. 30

    Google Scholar 

  21. Sievert, C., Shirley, K.: Package LDAvis

    Google Scholar 

  22. Natural Language Toolkit — NLTK 3.4.5 documentation. [En ligne]. Disponible sur: https://www.nltk.org/. [Consulté le: 17-févr-2020]

  23. Loria, S.: textblob documentation. Release 0.15, 2 1–73 (2018)

    Google Scholar 

  24. Rehurek, R.: gensim: Python framework for fast vector space modelling . [En ligne]. Disponible sur: https://pypi.org/project/gensim/. [Consulté le: 26-févr-2020]

  25. Sievert, C., Shirley, K.: LDAvis: a method for visualizing and interpreting topics. In: Proceedings of the Workshop on Interactive Language Learning, Visualization, and Interfaces, Baltimore, Maryland, USA, pp. 63–70 (2014). https://doi.org/10.3115/v1/W14-3110

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2022 The Author(s), under exclusive license to Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Habbat, N., Anoun, H., Hassouni, L. (2022). Exploration, Sentiment Analysis, Topic Modeling, and Visualization of Moroccan Twitter Data. In: Kacprzyk, J., Balas, V.E., Ezziyyani, M. (eds) Advanced Intelligent Systems for Sustainable Development (AI2SD’2020). AI2SD 2020. Advances in Intelligent Systems and Computing, vol 1418. Springer, Cham. https://doi.org/10.1007/978-3-030-90639-9_87

Download citation

Publish with us

Policies and ethics