Skip to main content

sentence_count

Function sentence_count 

Source
pub fn sentence_count(text: &str) -> usize
Expand description

Count sentences by runs of terminal punctuation (., !, ?). Non-empty text with no terminator counts as one sentence.

A . is not treated as a sentence end when it is a decimal point (digit on both sides) or part of an initialism (immediately followed by another letter/digit), which avoids over-counting 3.14 and U.S.A.. Runs of terminators (e.g. ... or ?!) collapse to one. Trailing abbreviation dots (Dr.) can still be over-counted by one — full abbreviation handling is out of scope.