首页 > 解决方案 > CleanNLP 中的 CoreNLP - 运行时错误“Expected dtype int64 for index”

问题描述

Error in py_call_impl(callable, dots$args, dots$keywords) : RuntimeError: index_select(): Expected dtype int64 for index当我尝试通过 R 中的 CleanNLP 对较长的文本字符串(我认为这是触发问题的原因)运行 corenlp时遇到错误。

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()

在此示例文本 tibble 上运行它可以工作:

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

我怎样才能解决这个问题?我要处理的文本每一个都比一个短句长得多。

标签: rnlpstanford-nlpreticulate

解决方案


这可能会发生,因为stanfordnlp它已过时且未维护。

这是其 Github 问题中的一个已知问题https://github.com/stanfordnlp/stanfordnlp/issues/6


推荐阅读