/**
* 根据标点符号进行句子拆分,并且保留句子结尾符号
*
*/
public String[] splitSentence(String cmt){
/*正则表达式:句子结束符*/
String regEx=",|\\.|\\?|!|:|;|~|,|:|。|!|;|?| ";
Pattern p =Pattern.compile(regEx);
Matcher m = p.matcher(cmt);
/*按照句子结束符分割句子*/
String[] words = p.split(cmt);
/*将句子结束符连接到相应的句子后*/
if(words.length > 0)
{
int count = 0;
while(count < words.length)
{
if(m.find())
{
words[count] += m.group();
}
count++;
}
}
/*输出结果*/
return words;
}
句子分割 保留标点符号
最新推荐文章于 2024-09-04 14:56:52 发布