How to 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.
count(BreakIterator bi, String source) method we iterates the the break to extract sentences that composes the paragraph which value is stored in the
Our program will print the following result on the console screen:
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