Example #1
0
        static void Main(string[] args)
        {
            /// <summary>
            /// Feladat Tétel:
            /// Legyen A és B két string. Azt mondjuk, hogy A és B ciklikusan ekvivalens, ha létezik
            /// olyan U és V string, melyre A=UV, B=VU.
            /// Például, ha A=’12345’ és B=’34512’ , akkor A és B ciklikusan ekvivalensek (U=’12’ , V=’345’ ).
            /// Ha C=’12435’ , akkor A és C nem ciklikusan ekvivalensek.
            ///
            /// Feladat Spcifikáció
            /// Legyen adott egy T szöveg (text fájlból beolvasandó).
            /// Keressük meg azt a T-beli szót, amelynek a legtöbb ciklikusan elforduló ekvivalense szerepel T-ben.
            /// A talált szót és a vele ekvivalens szavakat írjuk ki.
            /// </summary>

            Console.WriteLine("IMK10Y\nSTART");
            Utils.Separator(0);

            Console.WriteLine("1. Initating filehandler object...");
            Console.WriteLine("Give the full path to the file: ");
            string path = Console.ReadLine();
            FileHandler fileHandler = new FileHandler();
            string fileContentAsOneString = fileHandler.OpenFileAndGetContentAsString(path);
            Utils.Separator(1);

            Console.WriteLine("2. Removing punctuations...");
            fileContentAsOneString = Utils.RemovePunctuations(fileContentAsOneString);
            Utils.Separator(1);

            Console.WriteLine("3. Converting the text to lowercase...");
            fileContentAsOneString = Utils.ConvertStringToLowerCase(fileContentAsOneString);
            Utils.Separator(1);

            Console.WriteLine("4. Split the text into words...");
            List<string> wordList = Utils.SplitWords(fileContentAsOneString);
            Utils.Separator(2);

            Console.WriteLine("5. Creating analyzer object...");
            CyclicRedundancyAnalyzer analyzer = new CyclicRedundancyAnalyzer();

            List<string> maxMatchesInWholeText = new List<string>();

            for (int i = 0; i < wordList.Count; i++)
            {
                List<string> resultsForActualWord = analyzer.CountRedundancy(wordList);
                if (maxMatchesInWholeText.Count() < resultsForActualWord.Count())
                {
                    maxMatchesInWholeText = resultsForActualWord.ToList<string>();
                    Console.WriteLine("The maximum of cyclic redundancy matches is: "+maxMatchesInWholeText.Count());
                    Console.Write("The words: ");
                    foreach (var item in maxMatchesInWholeText)
                    {
                        Console.Write(item + " ");
                    }
                    Console.WriteLine();
                }
            }
            Utils.Separator(2);
            Console.WriteLine("END");
            Console.ReadLine();
        }