2017-08-29 66 views
0

的错误是:

> lda_model = LDA$new(n_topics = 3, vocabulary = vocab, doc_topic_prior = 0.1, topic_word_prior = 0.01) 
Error in .subset2(public_bind_env, "initialize")(...) : 
    unused argument (vocabulary = list(term = c("normal", "bobo", "lixo", "sozinho", "triste", "santo", "dificil", "homem", "querido", "doido", "puta", "namorado", "viciado", "grosso", "anjo", "maravilhoso", "otario", "ciumento", "feio", "pessimo", "idiota", "bonito", "capaz", "otimo", "pior", "serio", "foda", "ruim", "fofo", "merda", "lerdo", "novo", "velho", "mal", "chato", "legal", "feliz", "burro", "unico", "trouxa", "boa", "ninguem", "lindo", "melhor", "amigo", "louco", "apaixonado"), term_count = c(205, 
215, 219, 222, 223, 232, 235, 241, 251, 261, 263, 264, 274, 276, 280, 280, 282, 284, 305, 311, 323, 333, 352, 354, 355, 363, 369, 380, 397, 405, 411, 421, 434, 458, 544, 577, 589, 628, 638, 690, 796, 826, 896, 936, 1177, 1251, 1344), doc_count = c(191, 187, 166, 212, 196, 214, 218, 219, 231, 205, 239, 230, 249, 235, 242, 253, 258, 256, 242, 278, 296, 275, 310, 314, 332, 319, 324, 345, 315, 341, 339, 356, 365, 409, 466, 480, 500, 525, 577, 557, 670, 707, 702, 785, 972, 981, 
> 

我在词汇,分词器和dtm成功创建后运行LDA$new时出现错误。完整的代码是:

current_dir_files = list.files(path = ".", full.names = TRUE) 
files_iterator = ifiles(current_dir_files, reader = read_file) 
it_tokens <- itoken(files_iterator, preprocess_function = tolower, 
        tokenizer = word_tokenizer, progressbar = TRUE) 
vocab <- create_vocabulary(it_tokens, stopwords = words.remove) %>% 
    prune_vocabulary(term_count_min = 200, doc_proportion_max = 0.1) 

vec <- vocab_vectorizer(vocabulary = vocab) 

dtm <- create_dtm(it = it_tokens, vectorizer = vec) 

lda_model = LDA$new(n_topics = 3, vocabulary = vocab, doc_topic_prior = 0.1, topic_word_prior = 0.01) 

我使用'text2vec'版本0.5.0,R 3.4.1 64位,RStudio 1.0.153。

回答

0

请检查文档 - ?LDAhttp://text2vec.org/topic_modeling.html#latent_dirichlet_allocation。从text2vec 0.4开始,函数的签名被改变了,现在不应该有vocabulary的参数。

+0

感谢您的及时答复。我使用软件包的以前版本编写代码,并且它正在工作。恭喜这个套餐,它真的很棒。 –

+0

请接受答案 –