【问题标题】:R openNLP could not find function sentDetect()R openNLP 找不到函数 sentDetect()
【发布时间】:2013-08-24 14:20:50
【问题描述】:

我正在使用一些包(webmining、sentiment、openNLP)来提取一些关于股票 JPM 的句子,但运行时出现以下错误:

eval(expr, envir, enclos) 中的错误:找不到函数“sentDetect”

这是我使用的代码,我确保所有软件包都已安装。我检查了“语料库”变量,它是“包含 20 个文本文档的语料库”。我还使用“library(help=openNLP)”列出了“openNLP”包中的所有函数,但在列表中没有找到“sentDetect”。

library(XML)
library(tm)
library(tm.plugin.webmining)
library(tm.plugin.sentiment)
library(NLP)
library(openNLP)

stock <-"JPM"
corpus <- WebCorpus(GoogleFinanceSource(stock))

sentences <- sentDetect(corpus)

这里是运行环境。是否可能与 R 3.0.1 版本(对于 openNLP 来说太新)或 64 位 Windows 系统有关?

R 版本 3.0.1 (2013-05-16) -- “好运动” 版权所有 (C) 2013 统计计算 R 基金会 平台:x86_64-w64-mingw32/x64(64位)

非常感谢。

维宏

【问题讨论】:

标签: r opennlp


【解决方案1】:

尝试使用“qdap”包

library("qdap")

然后使用函数'sent_detect'

sent_detect(xyz)

【讨论】:

  • 这对我有用,与使用 Maxent_Sent_Token_Annotator 的答案不同
【解决方案2】:

sentDetect 函数已被替换。新的句子分词方法见?Maxent_Sent_Token_Annotator

require("NLP")
require("openNLP")
## Some text.
s <- paste(c("Pierre Vinken, 61 years old, will join the board as a ",
             "nonexecutive director Nov. 29.\n",
             "Mr. Vinken is chairman of Elsevier N.V., ",
             "the Dutch publishing group."),
           collapse = "")
s <- as.String(s)

sent_token_annotator <- Maxent_Sent_Token_Annotator()
sent_token_annotator
a1 <- annotate(s, sent_token_annotator)
a1
## Extract sentences.
s[a1]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-05-16
    • 2015-11-06
    • 2019-07-08
    • 2018-05-29
    • 2014-04-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多