From 48f42ea9a5df7d60fa1c645ce8eb7941845d7d76 Mon Sep 17 00:00:00 2001 From: "Lars O. Grobe" Date: Wed, 31 Jan 2024 20:59:10 +0100 Subject: [PATCH] Set default algorithm back to ldamulticore, which requires to define a main() function in the calling module. --- litstudy/nlp.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/litstudy/nlp.py b/litstudy/nlp.py index 81f3580..b939e6e 100644 --- a/litstudy/nlp.py +++ b/litstudy/nlp.py @@ -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]) @@ -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