Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_docs_topics() Error: The size of nm (8) must be compatible with the size of x (18). #3

Open
mpickard-niu opened this issue Feb 9, 2023 · 0 comments

Comments

@mpickard-niu
Copy link

First, thanks for creating gensimr!

I'm trying to follow the topic modeling tutorial with my own data set. Everything works up to

wrapped_corpus_docs <- get_docs_topics(lda_topics)

where I get this error:

Error in `purrr::set_names()`:
! The size of `nm` (8) must be compatible with the size of
  `x` (18).
Backtrace:
 1. gensimr::get_docs_topics(lda_topics)
 5. rlang::abort(message = message)

Here's the code in context:

docs <- prepare_documents(gc_df$body)
dict <- corpora_dictionary(docs)
corpus_bow <- doc2bow(dict, docs)
(corpus_mm <- serialize_mmcorpus(corpus_bow, 
                                 file = "data/gc_corpus.mm",
                                 auto_delete = FALSE))

tfidf <- model_tfidf(corpus_mm)
corpus_tranformed <- wrap(tfidf, corpus_bow)

lda <- model_lda(corpus_tranformed, id2word = dict, num_topics =4L)
lda_topics <- lda$get_document_topics(corpus_bow)
wrapped_corpus_docs <- get_docs_topics(lda_topics)

Things work if I set num_topics = 2L (or 3 topics) when I create the LDA model with model_lda(), but when I try to model larger number of topics, I get that error. Am I doing something wrong? Or is this a bug?

Thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant