C#统计文本单词的个数
2013-04-23 13:29
411 查看
private void textBox1_TextChanged(object sender, EventArgs e) { textBox2.Text = getWordSum(textBox1.Text).ToString(); } private int getWordSum(string text) { string textbasic = text; char[] basictemp = text.ToCharArray(); int chfrom = Convert.ToInt32("4e00", 16); //范围(0x4e00~0x9fff)转换成int(chfrom~chend) int chend = Convert.ToInt32("9fff", 16); foreach (char c in basictemp) { if (' ' != c) { string temp = c.ToString(); int firstcode = char.ConvertToUtf32(temp, 0); if (firstcode >= chfrom && firstcode <= chend) { textbasic = textbasic.Replace(c, ' '); } } } char[] ch = new char[] { ' ', ',', '?', '!', '(', ')', '\n' }; string[] stemp = textbasic.Split(ch, StringSplitOptions.RemoveEmptyEntries); return stemp.Length; }
相关文章推荐
- 统计文本英文单词总个数,并列出每个单词的个数
- Python 统计文本中单词的个数
- 统计文本单词个数,并个数大小按序排列 C#
- C#统计英文文本中的单词数并排序
- C#统计文本单词个数2
- 【ThinkingInC++】4、统计txt文本中单词的个数
- 实验四-1 统计文本单词的个数
- 统计文本中每个单词的个数
- 统计文本单词的个数
- 第四章实验:统计文本单词的个数
- C语言统计一篇英文短文中单词的个数实例代码
- 输入一个字符串,统计其中单词的个数
- 如何统计一段英文中的单词的个数
- 软件工程作业------分析文本文档,统计出现频率最多的十个单词
- 判断是否为素数和统计字符串中单词的个数
- 3.2.1 泛型例子,泛型字典统计文本中的单词数
- 【python】统计文本中出现最多次的单词
- 如何使用linux命令统计文本中某个单词的出现频率
- 计算txt文本中单词的个数
- 统计单词个数