Weihong Zhang
Weihong Zhang

Reputation: 71

R openNLP could not find function sentDetect()

I am using a few packages (webmining, sentiment, openNLP) to extract some sentences about a stock JPM, but running in the following error:

Error in eval(expr, envir, enclos) : could not find function "sentDetect"

Here is the codes I used and I made sure that all packages are installed. I checked the "corpus" variable and it is "a corpus with 20 text documents". I also used "library(help=openNLP)" to list all the functions in the package "openNLP" but did not find "sentDetect" in the list.

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)

Here is the running environment. Is it possibly related to the R 3.0.1 version (too new for openNLP) or 64-bit Windows system?

R version 3.0.1 (2013-05-16) -- "Good Sport" Copyright (C) 2013 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 (64-bit)

Thank you very much.

Weihong

Upvotes: 3

Views: 5403

Answers (2)

Felix S
Felix S

Reputation: 1819

The sentDetect function has been replaced. See ?Maxent_Sent_Token_Annotator for the new way of tokenizing sentences:

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]

Upvotes: 3

Sushant Magoo
Sushant Magoo

Reputation: 374

try using 'qdap' package

library("qdap")

then use function 'sent_detect'

sent_detect(xyz)

Upvotes: 4

Related Questions