【发布时间】:2021-02-19 07:53:09
【问题描述】:
当我尝试通过 R 中的 CleanNLP 对较长的文本字符串运行 corenlp 时遇到错误 Error in py_call_impl(callable, dots$args, dots$keywords) : RuntimeError: index_select(): Expected dtype int64 for index(我认为这是触发问题的原因)。
library(reticulate)
Sys.setenv(RETICULATE_PYTHON = 'C:/Users/myname/AppData/Local/r-miniconda/envs/r-reticulate')
py_discover_config(required_module="cleannlp")
# Initialise model
cnlp_init_corenlp()
在这个示例文本上运行它可以工作:
justtext <- tibble(
id = 1:3,
text = c("Let me be the one you call.
If you jump, I'll break your fall.",
"Let me be the one you call.
If you jump, I'll break your fall.",
"Let me be the one you call. If you jump, I'll break your fall.")
)
cnlp_annotate(justtext)
但是,当我延长一串文本时遇到问题,如下所示:
justtext <- tibble(
id = 1:3,
text = c("Let me be the one you call.
If you jump, I'll break your fall.",
"Let me be the one you call.
If you jump, I'll break your fall.",
"Let me be the one you call. If you jump, I'll break your fall the quick brown fox jumped over the lazy dog.")
)
cnlp_annotate(justtext)
Error in py_call_impl(callable, dots$args, dots$keywords) : RuntimeError: index_select(): Expected dtype int64 for index
我该如何解决这个问题?我要处理的文本比一个短句长得多。
【问题讨论】:
标签: r nlp stanford-nlp reticulate