コード例 #1
0
        public int ins_select(string[] array, int i, word_len len, word_more more)
        {
            int flag = 0;

            if (array[i].Equals(str1, StringComparison.OrdinalIgnoreCase) == true)
            {
                file_path.input_path = array[i + 1];
                flag = 1;
            }
            else if (array[i].Equals(str2, StringComparison.OrdinalIgnoreCase) == true)
            {
                len.Wordlen = Convert.ToInt32(array[i + 1]);
                //result.WL.Wordlen = Convert.ToInt32(array[i+1]);
                flag = 2;
            }
            else if (array[i].Equals(str3, StringComparison.OrdinalIgnoreCase) == true)
            {
                //result.WM.Wordmore = Convert.ToInt32(array[i + 1]);
                more.Wordmore = Convert.ToInt32(array[i + 1]);
                flag          = 4;
            }
            else if (array[i].Equals(str4, StringComparison.OrdinalIgnoreCase) == true)
            {
                file_path.output_path = array[i + 1];
                flag = 8;
            }
            else
            {
                flag = -16;
            }
            return(flag);
        }
コード例 #2
0
ファイル: result.cs プロジェクト: Loserhqs/WordCount
        public void print_word(word_len len)
        {
            Dictionary <string, int> frequent = new Dictionary <string, int>();
            //统计单词的频数
            Dictionary <string, int> frequency_temp = word_count.word_frequency(ref frequent, len.Wordlen);
            Dictionary <string, int> dic1           = frequency_temp.OrderBy(o => o.Key).ToDictionary(o => o.Key, p => p.Value);
            //单词总数量
            int word_index = word_count.word_sum(dic1);

            Console.WriteLine("words:" + word_index);
        }
コード例 #3
0
        public void instruction(word_len len, word_more more)
        {
            ill2.illu_function();
            Console.WriteLine("input your instructions");
            string all_char = Console.ReadLine();

            string[] ins_arr = all_char.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            int      ind_sum = 0;

            for (int i = 0; i < ins_arr.Length; i = i + 2)
            {
                ind_sum = ind_sum + inp1.ins_select(ins_arr, i, len, more);
            }
            inp1.ins_right(ind_sum, len, more);
        }
コード例 #4
0
        public void nointrction(word_len len, word_more more)
        {
            Console.WriteLine("the input path:");
            string inputpath = Console.ReadLine();

            file_path.input_path = inputpath;
            //result.Word_more = 10;
            //result.Word_len = 0;
            Console.WriteLine("the output path:");
            string outputpath = Console.ReadLine();

            file_path.output_path = outputpath;
            //re1.WM.Wordmore = 10;
            re1.print_char();
            re1.print_word(len);
            re1.print_lines();
            re1.print_wordsort(more.Wordmore, len);
        }
コード例 #5
0
ファイル: result.cs プロジェクト: Loserhqs/WordCount
        public void print_wordsort(int word_temp, word_len len)
        {
            int word_sum = 0;
            Dictionary <string, int> frequent       = new Dictionary <string, int>();
            Dictionary <string, int> frequency_temp = word_count.word_frequency(ref frequent, len.Wordlen);
            Dictionary <string, int> dic2           = frequency_temp.OrderByDescending(o => o.Value).ThenBy(o => o.Key).ToDictionary(o => o.Key, p => p.Value);

            foreach (KeyValuePair <string, int> entry in dic2)
            {
                if (word_sum == word_temp)
                {
                    break;
                }
                string word     = entry.Key;
                int    fre_temp = entry.Value;
                word_sum++;
                Console.WriteLine("{0}:{1}", word, fre_temp);
            }
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: Loserhqs/WordCount
        //文件路径 file_path
        //单词总数 word_sum
        //单词频数 word_frequency
        static void Main(string[] args)
        {
            word_len     WL1  = new word_len(0);
            word_more    WM1  = new word_more(10);
            illustration ill1 = new illustration();
            select_way   sw1  = new select_way();

            ill1.illu_way();
            int cmd_num = Convert.ToInt32(Console.ReadLine());

            switch (cmd_num)
            {
            case 1: sw1.instruction(WL1, WM1);
                break;

            case 2: sw1.nointrction(WL1, WM1);
                break;

            default: sw1.the_error();
                break;
            }
            Console.ReadKey();
        }
コード例 #7
0
 public void ins_right(int x, word_len len, word_more more)
 {
     if (x > 0)
     {
         if (x % 2 == 0)
         {
             Console.WriteLine("need a input file");
             Console.ReadKey();
         }
         else
         {
             if (x == 1)
             {
                 //result.Word_more = 10;
                 file_path.output_path = "output.txt";
                 //result.Word_len = 0;
                 re2.print_char();
                 re2.print_word(len);
                 re2.print_lines();
                 re2.print_wordsort(more.Wordmore, len);
             }
             else if (x == 3)
             {
                 //result.Word_more = 10;
                 file_path.output_path = "output.txt";
                 re2.print_char();
                 re2.print_word(len);
                 re2.print_lines();
                 re2.print_wordsort(more.Wordmore, len);
                 re2.print_selectedlong(len.Wordlen);
             }
             else if (x == 5)
             {
                 file_path.output_path = "output.txt";
                 //result.Word_len = 0;
                 re2.print_char();
                 re2.print_word(len);
                 re2.print_lines();
                 re2.print_wordsort(more.Wordmore, len);
             }
             else if (x == 7)
             {
                 file_path.output_path = "output.txt";
                 re2.print_char();
                 re2.print_word(len);
                 re2.print_lines();
                 re2.print_wordsort(more.Wordmore, len);
                 re2.print_selectedlong(len.Wordlen);
             }
             else if (x == 9)
             {
                 //result.Word_more = 10;
                 //result.Word_len = 0;
                 re2.print_char();
                 re2.print_word(len);
                 re2.print_lines();
                 re2.print_wordsort(more.Wordmore, len);
             }
             else if (x == 11)
             {
                 //result.Word_more = 10;
                 re2.print_char();
                 re2.print_word(len);
                 re2.print_lines();
                 re2.print_wordsort(more.Wordmore, len);
                 re2.print_selectedlong(len.Wordlen);
             }
             else if (x == 13)
             {
                 //result.Word_len = 0;
                 re2.print_char();
                 re2.print_word(len);
                 re2.print_lines();
                 re2.print_wordsort(more.Wordmore, len);
             }
             else
             {
                 re2.print_char();
                 re2.print_word(len);
                 re2.print_lines();
                 re2.print_wordsort(more.Wordmore, len);
                 re2.print_selectedlong(len.Wordlen);
             }
         }
     }
     else
     {
         Console.WriteLine("the wrong instruction");
         Console.ReadKey();
     }
 }