【问题标题】:LDA$new model constructor text2vec R package error: Error in .subset2(public_bind_env, "initialize")(...) : unused argument (...)LDA$new 模型构造函数 text2vec R 包错误:.subset2 中的错误(public_bind_env,“initialize”)(...):未使用的参数(...)
【发布时间】:2017-08-29 01:10:09
【问题描述】:

错误是:

> 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。

【问题讨论】:

    标签: r nlp text-mining lda text2vec


    【解决方案1】:

    请查看文档 - ?LDAhttp://text2vec.org/topic_modeling.html#latent_dirichlet_allocation。自 text2vec 0.4 起更改了函数签名,现在不应有 vocabulary 参数。

    【讨论】:

    • 感谢您的及时答复。我使用以前版本的包编写了代码并且它正在工作。恭喜收到礼包,真的很棒。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-05-09
    • 1970-01-01
    • 2012-04-18
    • 2014-07-06
    • 1970-01-01
    • 2012-03-25
    相关资源
    最近更新 更多