Exemplo n.º 1
0
        //Разбиение строки на слова, выборка и подсчёт триплетов
        static void FrequencyAnalysis(int index, ParallelLoopState pls)
        {
            char[]   delimeters = { ' ', '\t' };
            string[] words      = lines[index].Split(delimeters);

            if (isEnd == true)             //Прерывание цикла при нажатии клавиши
            {
                pls.Break();
            }
            for (int i = 0; i < words.Length; i++)
            {
                //Console.WriteLine("we here");
                if (words[i].Length >= 3)
                {
                    for (int j = 0; j <= words[i].Length - 3; j++)
                    {
                        //Console.WriteLine("we here2");

                        string strTriplet = words[i].Substring(j, 3);
                        if (IsLetterWord(strTriplet))
                        {
                            Triplet triplet = new Triplet(strTriplet);
                            if (!IsListContains(triplets, triplet))
                            {
                                triplets.Add(triplet);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
 //Проверка на вхождение триплета в список
 static bool IsListContains(List <Triplet> list, Triplet triplet)
 {
     for (int i = 0; i < list.Count; i++)
     {
         if (list[i].Value == triplet.Value)
         {
             list[i].count++;
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 3
0
 //Сортировка вставками по убыванию
 static void InsertionSort(List <Triplet> list)
 {
     for (int i = 0; i < list.Count - 1; i++)
     {
         for (int j = i + 1; j > 0; j--)
         {
             if (list[j - 1].count < list[j].count)
             {
                 Triplet temp = list[j - 1];
                 list[j - 1] = list[j];
                 list[j]     = temp;
             }
         }
     }
 }