r - 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
我怎样才能解决这个问题?我要处理的文本每一个都比一个短句长得多。
解决方案
这可能会发生,因为stanfordnlp
它已过时且未维护。
这是其 Github 问题中的一个已知问题https://github.com/stanfordnlp/stanfordnlp/issues/6
推荐阅读
- flutter - 当我导航回上一个屏幕时,为什么我的数据会重置?
- physics-engine - rotate(angle) 和 Matter.Body.rotate(body, angle) 有什么区别?使用 matter.min.js 库。何时以及为什么要一起使用它们?
- android - api30 之间的 api21 是否支持 avif?
- java - 在 AWS Kinesis 上上传媒体时获取“ErrorCode”:“KMS_KEY_ACCESS_DENIED”、“ErrorId”:4500
- javascript - Slick JS 和自定义动画
- javascript - 使用“react-slot-machine-gen”npm 包中的 SlotMachine 组件
- asp.net-core - 将 Letsencrypt SSL 添加到 nginx 后 SignalR 失败
- javascript - 为 React-Leaflet CSS SVG 路由动画附加 onAnimationEnd
- git - 我的合并拉取请求在我的 GitHub 活动概述中被视为提交?
- arduino - 什么是以及如何在 macOS 上上传 Arduino 二进制文件 .ino.bin 和 .ino.elf 文件?