JVM Languages

Tools

How do I breaks a paragraph into sentences?

This example show you how to use the BreakIterator.getSentenceInstance() to breaks a paragraphs into sentences that composes the paragraph. To get the BreakIterator instance we call the getSentenceInstance() factory method and passes a locale information.

In the count(BreakIterator bi, String source) method we iterates the the break to extract sentences that composes the paragraph which value is stored in the paragraph variable.

sentence = Line boundary analysis determines where a text string can be broken when line-wrapping.
sentence = The mechanism correctly handles punctuation and hyphenated words.
sentence = Actual line breaking needs to also consider the available line width and is handled by higher-level software.
Number of sentences: 3