C# 划分英文句子

来源:百度知道 编辑:UC知道 时间:2024/05/24 10:17:07
Jarvis’s mother, Anna Maria Reeves Jarvis, was an activist during the Civil War and lost 8 of her 12 children before
they reached adulthood. When she died in 1905, Anna (daughter) was distraught and vowed to devote her life to honoring her
mother. Her devotion led her to strive to appoint an official U.S. holiday to recognize mothers. Though Mother’s Day had
been celebrated informally for many years, Jarvis wrote many important figures (including U.S. congressmen and prosperous
businessmen), imploring them to back Mother’s Day as an official holiday.

用C#把上面一段话划分句子,求代码(如果能成的话另加分)
注:上面的逗号不算一句话,核心就是怎么能不把U.S.也划分成句子。
看来是我没给你们说清楚,除了U.S.之类的词外,还有很多像Mr.Zhang has a book.里面的Mr.之类的关键词,怎么才能区分开,谢谢。

String str = @"Jarvis’s mother, Anna Maria Reeves Jarvis, was an activist during the Civil War and lost 8 of her 12 children before
they reached adulthood. When she died in 1905, Anna (daughter) was distraught and vowed to devote her life to honoring her
mother. Her devotion led her to strive to appoint an official U.S. holiday to recognize mothers. Though Mother’s Day had
been celebrated informally for many years, Jarvis wrote many important figures (including U.S. congressmen and prosperous
businessmen), imploring them to back Mother’s Day as an official holiday. ";

//上面的是你的文本段,记得加@

String[] s = str.Split('.');

for (int i = 0; i < s.Length;i++ )
{
if (s[i].Equals("S"))
{
s[i - 1] = s[i - 1] + "."+s[i];
s[i] = "";
}