Topic Modeling on Hobbes's Leviathan with Gensim
Topic Modeling with Gensim: Hobbes's Leviathan
This project demonstrates how to perform topic modeling on a large text file using the Gensim library in Python. The text file used in this project is Hobbes's Leviathan, which is available on Project Gutenberg.
Prerequisites To run this project, you will need the following:
Python 3.x
Gensim
pyLDAvis
Jupyter Notebook or Google Colaboratory (optional)
Getting Started
To get started with this project, follow these steps:
Download or clone this repository to your local machine. Download the Hobbes's Leviathan text file from Project Gutenberg and save it as leviathan.txt in the repository directory. Open the topic_modeling.ipynb notebook in Jupyter Notebook or Google Colaboratory. Run the notebook cells to preprocess the text, train the topic model, and visualize the results using pyLDAvis.
Files
This repository contains the following files:
topic_modeling.ipynb: a Jupyter Notebook containing the code for preprocessing the text, training the topic model, and visualizing the results.
leviathan.txt: the Hobbes's Leviathan text file downloaded from Project Gutenberg.
README.md: this README file.
Acknowledgements
This project was inspired by and adapted from various online resources, including:
Gensim documentation: https://radimrehurek.com/gensim/auto_examples/index.html Topic Modeling with Gensim: https://www.machinelearningplus.com/nlp/topic-modeling-gensim-python/ Interactive topic model visualization with pyLDAvis: https://nbviewer.jupyter.org/github/bmabey/pyLDAvis/blob/master/notebooks/pyLDAvis_overview.ipynb