When completing the configuration, You need to count the frequency of occurrence of words (the word has been rough cut) in the Chinese corpus. Think of the number of each character in the statistical string when we start to learn the C language, I just want to use C # To implement it. I found that the generic collection class Dictionary is very useful. Just a few lines of code will be done. It's great!
1 private static void FnCountWord ()
2 {
3 String text = Console. ReadLine ();
4 Dictionary <Char, int> charDict = new Dictionary <char, int> ();
5 for (int I = 0; I <text. Length; I ++)
6 {
7 if (charDict. ContainsKey (text [I]) = true)
8 {
9 charDict [text [I] ++;
10}
11 else
12 {
13 charDict. Add (text [I], 1 );
14}
15}
16 // int number, number of Char characters in KeyValuePair <char, int>, and number of int statistical characters
17 Dictionary <int, KeyValuePair <Char, int> charID = new Dictionary <int, KeyValuePair <Char, int> ();
18 int k = 0;
19 foreach (KeyValuePair <Char, int> charInfo in charDict)
20 &