If you just want to count the stopwords you cloud do something like,

library(slam)
library(tm)

your_string <- "Mhm . Alright . There's um a young boy that's getting a cookie 
jar . And it he's uh in bad shape because uh the thing is falling over . And in 
the picture the mother is washing dishes and doesn't see it . And so is the the 
water is overflowing in the sink . And the dishes might get falled over if you 
don't fell fall over there there if you don't get it . And it there it's a 
picture of a kitchen window . And the curtains are very uh distinct . But the 
water is still flowing ."
corp <- Corpus(VectorSource(your_string))

stopwords("en")

cntrl <- list(tolower=TRUE, stopwords = NULL,
              removePunctuation = FALSE, removeNumbers = TRUE, 
              stemming = FALSE, wordLengths = c(0, Inf))


dtm <- DocumentTermMatrix(corp, cntrl)

col_sums(dtm[, which(colnames(dtm) %in% stopwords("en"))])



Best,
Florian
 

Gesendet: Montag, 12. Juni 2017 um 16:12 Uhr
Von: "Bert Gunter" <bgunter.4...@gmail.com>
An: "Elahe chalabi" <chalabi.el...@yahoo.de>
Cc: "R-help Mailing List" <r-help@r-project.org>
Betreff: Re: [R] count number of stop words in R
You can use regular expressions.

?regex and/or the stringr package are good places to start. Of
course, you have to define "stop words."


Cheers,
Bert


Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Mon, Jun 12, 2017 at 5:40 AM, Elahe chalabi via R-help
<r-help@r-project.org> wrote:
> Hi all,
>
> Is there a way in R to count the number of stop words (English) of a string 
> using tm package?
>
> str="Mhm . Alright . There's um a young boy that's getting a cookie jar . And 
> it he's uh in bad shape because uh the thing is falling over . And in the 
> picture the mother is washing dishes and doesn't see it . And so is the the 
> water is overflowing in the sink . And the dishes might get falled over if 
> you don't fell fall over there there if you don't get it . And it there it's 
> a picture of a kitchen window . And the curtains are very uh distinct . But 
> the water is still flowing .
>
> 255 Levels: A boy's on the uh falling off the stool picking up cookies . The 
> girl's reaching up for it . The girl the lady is is drying dishes . The water 
> is uh running over uh from the sink into the floor . The window's opened . 
> Dishes on the on the counter . She's outside ."
>
> Thanks for any help!
> Elahe
>
> ______________________________________________
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html[http://www.R-project.org/posting-guide.html]
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help[https://stat.ethz.ch/mailman/listinfo/r-help]
PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html[http://www.R-project.org/posting-guide.html]
and provide commented, minimal, self-contained, reproducible code.

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to