Skip to content

Instantly share code, notes, and snippets.

@khuangaf
Last active February 2, 2020 07:30
Show Gist options
  • Save khuangaf/e39fdf01a5a9954186128a034b480e58 to your computer and use it in GitHub Desktop.
Save khuangaf/e39fdf01a5a9954186128a034b480e58 to your computer and use it in GitHub Desktop.
from gensim.test.utils import common_texts
from gensim.corpora.dictionary import Dictionary
from gensim.models import LdaModel
# Create a corpus from a list of texts
common_dictionary = Dictionary(common_texts)
common_corpus = [common_dictionary.doc2bow(text) for text in common_texts]
# Train the model on the corpus.
lda = LdaModel(common_corpus, num_topics=10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment