Sentence Boundaries

您可以使用BreakIterator确定句子边界。首先使用getSentenceInstance方法创建BreakIterator

BreakIterator sentenceIterator =
    BreakIterator.getSentenceInstance(currentLocale);

为了显示句子边界,该程序使用markBoundaries方法,这将在Word Boundaries部分中讨论。 markBoundaries方法在字符串 下方打印脱字号(^),以指示边界位置。这里有些例子:

She stopped.  She said, "Hello there," and then went on.
^             ^                                         ^

He's vanished!  What will we do?  It's up to us.
^               ^                 ^             ^

Please add 1.5 liters to the tank.
^                                 ^