static Dictionary<string, int> CountWord(string text) { Dictionary<string, int> frequency; frequency = new Dictionary<string,int>(); string[] words = Regex.Split(text,@"\W+"); foreach(string word in words) { if(frequency.ContainsKey(word)) { frequency[word]++; } else { frequency[word] = 1; } } return frequency; }
by: 发表于:2018-01-08 10:20:50 顶(0) | 踩(0) 回复
??
回复评论