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.
^ ^