我试图在R中运行textEmbed函数,设置需要:
require(quanteda)
require(quanteda.textstats)
require(udpipe)
require(reticulate)
#udpipe_download_model(language = "english")
ud_eng <- udpipe_load_model(here::here('english-ewt-ud-2.5-191206.udpipe'))
virtualenv_list()
reticulate::import('torch')
reticulate::import('numpy')
reticulate::import('transformers')
reticulate::import('nltk')
reticulate::import('tokenizers')
require(text)它运行以下代码
tmp1 <- textEmbed(x = 'sofa help',
model = 'roberta-base',
layers = 11)
tmp1$x但是,它不运行以下代码
tmp1 <- textEmbed(x = 'sofa help',
model = 'roberta-base',
layers = 11)
tmp1$x它给出了以下错误
Error in x[[1]] : subscript out of bounds
In addition: Warning message:
Unknown or uninitialised column: `words`. 如有任何建议,将不胜感激。
发布于 2022-05-02 13:11:16
我相信text-package的更新版本( .9.50版本和更高版本)已经修复了此错误。
(我看不出这两个代码部分有什么不同-但我认为这个错误与只向textEmbed提交一个令牌/单词有关,后者现在起作用了)。
此外,请参阅有关如何安装text-package http://r-text.org/articles/Extended_Installation_Guide.html的更新说明。
library(text)
library(reticulate)
# Install text required python packages in a conda environment (with defaults).
text::textrpp_install()
# Show available conda environments.
reticulate::conda_list()
# Initialize the installed conda environment.
# save_profile = TRUE saves the settings so that you don't have to run textrpp_initialize() after restarting R.
text::textrpp_initialize(save_profile = TRUE)
# Test so that the text package work.
textEmbed("hello")https://stackoverflow.com/questions/69633894
复制相似问题