首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在prepare_analogy_questions包中使用check_analogy_accuracy和text2vec函数?

如何在prepare_analogy_questions包中使用check_analogy_accuracy和text2vec函数?
EN

Stack Overflow用户
提问于 2017-11-14 14:10:52
回答 1查看 119关注 0票数 0

以下代码:

代码语言:javascript
复制
library(text2vec)
text8_file = "text8"
if (!file.exists(text8_file)) {
download.file("http://mattmahoney.net/dc/text8.zip", "text8.zip")
unzip ("text8.zip", files = "text8")
}
wiki = readLines(text8_file, n = 1, warn = FALSE)
# Create iterator over tokens
tokens <- space_tokenizer(wiki)
# Create vocabulary. Terms will be unigrams (simple words).
it = itoken(tokens, progressbar = FALSE)
vocab <- create_vocabulary(it)
vocab <- prune_vocabulary(vocab, term_count_min = 5L)
# Use our filtered vocabulary
vectorizer <- vocab_vectorizer(vocab)
# use window of 5 for context words
tcm <- create_tcm(it, vectorizer, skip_grams_window = 5L)
RcppParallel::setThreadOptions(numThreads = 4)
glove_model = GloVe$new(word_vectors_size = 50, vocabulary = vocab, x_max = 10, learning_rate = .25)
word_vectors_main = glove_model$fit_transform(tcm, n_iter = 20)
word_vectors_context = glove_model$components
word_vectors = word_vectors_main + t(word_vectors_context)

导致错误:

代码语言:javascript
复制
qlst <- prepare_analogy_questions("questions-words.txt", rownames(word_vectors))
> Error in (function (fmt, ...)  : 
  invalid format '%d'; use format %s for character objects

文件问题-来自word2vec sources https://github.com/nicholas-leonard/word2vec/blob/master/questions-words.txt的words.txt

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-11-15 07:08:13

这是信息消息格式设置中的一个小错误(在引入futille.logger之后)。把它和推到github修好了。

您可以使用devtools::install_github("dselivanov/text2vec"安装更新版本的包。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47287909

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档