文档

Java™ 教程
隐藏目录
句子边界
路径:国际化
课程:文本处理
章节:检测文本边界

句子边界

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

BreakIterator sentenceIterator =
    BreakIterator.getSentenceInstance(currentLocale);

为了显示句子边界,程序使用了在单词边界一节中讨论的markBoundaries方法。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.
^                                 ^

上一页: 单词边界
下一页: 行边界