You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用liwcalike调用quanteda 3.1.1时遇'textstat_readability'未导出错误求助

问题:调用liwcalike时出现'textstat_readability'未导出错误(quanteda 3.1.1版本)

我是R与quanteda的新手,这是首次使用liwcalike工具,也是第一次在Stack Overflow发帖。以下是测试代码:

txt <- c("The red-shirted lawyer gave her yellow-haired, red nose ex-boyfriend $300
            out of pity:(.")
dict <- quanteda::dictionary(list(people = c("lawyer", "boyfriend"),
                                  color_fixed = "red",
                                  color_glob = c("red*", "yellow*", "green*"),
                                  mwe = "out of"))

liwcalike(txt, dict, what = "word")

在RStudio运行代码时,调用liwcalike出现错误:'textstat_readability' is not an exported object from 'namespace:quanteda'。我的quanteda版本为3.1.1,请教代码问题所在?

解决方案

  • 问题根源:liwcalike函数依赖quanteda的textstat_readability函数,但quanteda 3.x版本已将textstat_readability从核心包移至quanteda.textstats扩展包,不再作为quanteda主包的导出对象。
  • 解决步骤:
    1. 安装并加载quanteda.textstats扩展包:
      install.packages("quanteda.textstats")
      library(quanteda.textstats)
      
    2. 重新运行原代码即可解决该错误。
  • 补充说明:quanteda 3.x版本开始采用模块化拆分,将文本统计、模型等功能拆分到独立扩展包,使用对应功能时需加载相应的扩展包。

内容的提问来源于stack exchange,提问作者JasonCruso

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.29 09:26:07