【问题标题】:CoreNLP in CleanNLP - Runtime error "Expected dtype int64 for index"CleanNLP 中的 CoreNLP - 运行时错误“Expected dtype int64 for index”
【发布时间】: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


    【解决方案1】:

    这可能是因为 stanfordnlp 已过时且未维护。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-06
      • 1970-01-01
      • 2019-09-04
      • 2021-04-28
      • 2021-08-14
      • 2020-08-19
      相关资源
      最近更新 更多