On Fri, Jun 15, 2012 at 1:48 AM, raishilpa <raishilpa.bhu at gmail.com>
wrote:> hello,
> I am using the following code
>
>>s<-"I am very happy, excited, and optimistic.I am very scared,
annoyed, and
> irritated.Iraq?s political crisis entered its second week one step closer
to
> the potential.dissolution of the government, with a call for elections by a
> vital coalition partner and a suicide attack that extended the spate of
> violence. that has followed the withdrawal.of U.S. troops"
>
>> sentDetect(s, language = "en")
> #getting output in the following way
>
> [1] "I am very happy, excited, and optimistic.I am very scared,
annoyed, and
> irritated.Iraq?s "
> [2] "political crisis entered its second week one step closer to the
> potential.dissolution "
> [3] "of the government, with a call for elections by a vital coalition
> partner and a suicide attack that extended the spate of violence. "
> [4] "that has followed the withdrawal.of "
> [5] "U.S. troops"
>
> I want output in some different way...since sentences [1] [2] [3] [4] [5]
> are from " s" I want output in following way
>
> [1] -"I am very happy, excited, and optimistic.I am very scared,
annoyed,
> and irritated.Iraq?s political crisis entered its second week one step
> closer to the potential.dissolution of the government, with a call for
> elections by a vital coalition partner and a suicide attack that extended
> the spate of violence. that has followed the withdrawal.of U.S.
troops"
> [1,1] ?"I am very happy, excited, and optimistic.I am very scared,
annoyed,
> and irritated.Iraq?s "
> [1,2] ?"political crisis entered its second week one step closer to
the
> potential.dissolution "
> [1,3] "of the government, with a call for elections by a vital
coalition
> partner and a suicide attack that extended the spate of violence. "
> [1,4] "that has followed the withdrawal.of "
> [1,5] "U.S. troops"
>
> or in some other way that you guys can suggest me...but remember one thing-
> under the main paragraph all the sentences should come so that it become
> easy to recognize the parent para of the sub-sentences.
Unfortunately, the structure you're asking for doesn't immediately
lend it self to one of R's main data-structures. Where I'd think of
wedging this in would be in a print method, but I'm not sure if that
fits your particular use case.
Something like this [un-tested]:
print.sentiment <- function(x, ...){
for(i in NROW(x)){
cat(paste(x[i,]), "\n")
print(x[i,])
}
}
with appropriate constructor.
Hopefully this will get you started,
Michael
>
> thanking you in anticipation
> Shilpa Rai
> MSc IIT Bombay
> .
>
>
>
>
>
> --
> View this message in context:
http://r.789695.n4.nabble.com/help-in-sentDetect-fuction-tp4633462.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.