Skip to main content

Topic Modeling and Sentiment Analysis with LDA and NMF on Moroccan Tweets

  • Conference paper
  • First Online:
Innovations in Smart Cities Applications Volume 4 (SCA 2020)

Part of the book series: Lecture Notes in Networks and Systems ((LNNS,volume 183))

Abstract

Twitter is one of the most popular social media platforms. Due to its simplicity of use and the services provided by twitter API, it is extensively used around the world, including Morocco. It provides huge volume of information and is considered as a large source of data for opinion mining.

The aim of this paper is to analyze Moroccan tweets, in order to generate some useful statistics, identify different sentiments, and extract then visualize predominant topics. In our research work, we collected 25 146 tweets using Twitter API and python language, and stored them into MongoDB database. Stored tweets were preprocessed by applying natural language processing techniques (NLP) using 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 to obtain meaningful data from Twitter, comparing and analyzing topics detected by two popular topic modeling algorithms; Non-negative Matrix Factorization (NMF) and Latent Dirichlet Allocation (LDA). The observed results show that LDA outperforms NMF in terms of their topic coherence.

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 169.00
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 219.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., 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. Proc. Comput. Sci. 142, 301–307 (2018). https://doi.org/10.1016/j.procs.2018.10.494

    Article  Google Scholar 

  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. Med. 15, 100059 (2020). https://doi.org/10.1016/j.osnem.2019.100059

    Article  Google Scholar 

  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

    Article  Google Scholar 

  7. Ray, S.K., Ahmad, A., Kumar, C.A.: Review and implementation of topic modeling in Hindi. Appl. Artif. Intell. 33(11), 979–1007 (2019).https://doi.org/10.1080/08839514.2019.1661576

  8. Greene, D., Cross, J.P.: Exploring the Political Agenda of the European Parliament Using a Dynamic Topic Modeling Approach. ArXiv160703055 Cs, juill. 2016, Consulté le: mai 30, 2020. [En ligne]. Disponible sur: https://arxiv.org/abs/1607.03055

  9. Pasquali, A.R.: Automatic coherence evaluation applied to Topic Models (2016)

    Google Scholar 

  10. Ilyas, S.H.W., Soomro, Z.T., Anwar, A., Shahzad, H., Yaqub, U.: «Analyzing Brexit’s impact using sentiment analysis and topic modeling on Twitter discussion», p. 7 (2020)

    Google Scholar 

  11. Dahal, B., Kumar, S.A.P., Li, Z.: Topic modeling and sentiment analysis of global climate change tweets. Soc. Netw. Anal. Min. 9(1), 24 (2019). https://doi.org/10.1007/s13278-019-0568-8

    Article  Google Scholar 

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

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

  14. Siddharth, S., Darsini, R., Sujithra, D.M.: Sentiment Analysis On Twitter Data Using Machine Learning Algorithms in Python, p. 15

    Google Scholar 

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

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

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

    Google Scholar 

  18. Chen, Y., et al.: Experimental explorations on short text topic mining between LDA and NMF based schemes. Knowl.-Based Syst. (2018). https://doi.org/10.1016/j.knosys.2018.08.011

    Article  Google Scholar 

  19. Mclachlan, G.J., Krishnan, T.: The EM Algorithm and Extensions. John Wiley (2007)

    Google Scholar 

  20. Nugraha, P., Rifky Yusdiansyah, M., Murfi, H.: Fuzzy C-means in lower dimensional space for topics detection on Indonesian online news. In: Tan, Y., Shi, Y. (eds.) Data Mining and Big Data, vol. 1071, pp. 269–276. Springer, Singapore (2019)

    Chapter  Google Scholar 

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

  22. Loria, S.: textblob Documentation, pp. 1–73 (2018)

    Google Scholar 

  23. 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]

  24. «scikit-learn: machine learning in Python—scikit-learn 0.23.1 documentation». https://scikit-learn.org/stable/ (consulté le juin 06, 2020)

  25. McCallum, A.: Mallet: A Machine Learning for Language Toolkit (2002)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Nassera Habbat .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2021 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. (2021). Topic Modeling and Sentiment Analysis with LDA and NMF on Moroccan Tweets. In: Ben Ahmed, M., Rakıp Karaș, İ., Santos, D., Sergeyeva, O., Boudhir, A.A. (eds) Innovations in Smart Cities Applications Volume 4. SCA 2020. Lecture Notes in Networks and Systems, vol 183. Springer, Cham. https://doi.org/10.1007/978-3-030-66840-2_12

Download citation

  • DOI: https://doi.org/10.1007/978-3-030-66840-2_12

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-030-66839-6

  • Online ISBN: 978-3-030-66840-2

  • eBook Packages: EngineeringEngineering (R0)

Publish with us

Policies and ethics