count the number of sentences

Share:

Description

Return the count of sentences in a corpus or character.

Usage

1
2
3
4
5
6
7
nsentence(x, ...)

## S3 method for class 'character'
nsentence(x, ...)

## S3 method for class 'corpus'
nsentence(x, ...)

Arguments

x

texts or corpus whose sentences will be counted

...

additional arguments passed to tokenize

Value

scalar count(s) of the total sentences per text

Note

'nsentence()' relies on the boundaries definitions in the stringi package (see stri_opts_brkiter). It does not count sentences correctly if the text has been transformed to lower case, and for this reason 'nsentence()' will stop with an error if it detects all lower-cased text.

Examples

1
2
3
4
# simple example
txt <- c(text1 = "This is a sentence: second part of first sentence.",
         text2 = "A word. Repeated repeated.")
nsentence(txt)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.