Skip to content

Commit

Permalink
Set default algorithm back to ldamulticore, which requires to define …
Browse files Browse the repository at this point in the history
…a main() function in the calling module.
  • Loading branch information
larsgrobe committed Jan 31, 2024
1 parent ffbf7d4 commit 48f42ea
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions litstudy/nlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,6 @@ def train_elda_model(corpus: Corpus, num_topics, num_models=4, seed=0, **kwargs)
:param kwargs: Arguments passed to `gensim.models.ensemblelda.EnsembleLda` (gensim4).
"""

dic = corpus.dictionary
freqs = corpus.frequencies

from importlib.metadata import version

gensim_mayor = int(version("gensim").split(".")[0])
Expand All @@ -362,10 +359,18 @@ def train_elda_model(corpus: Corpus, num_topics, num_models=4, seed=0, **kwargs)

exit("EnsembleLda requires at least gensim 4.")

dic = corpus.dictionary
freqs = corpus.frequencies

from gensim.models.ensemblelda import EnsembleLda

model = EnsembleLda(
corpus=freqs, id2word=dic, num_topics=num_topics, num_models=num_models, **kwargs
topic_model_class="ldamulticore",
corpus=freqs,
id2word=dic,
num_topics=num_topics,
num_models=num_models,
**kwargs
)

doc2topic = corpus2dense(model[freqs], num_topics).T
Expand Down

0 comments on commit 48f42ea

Please sign in to comment.