private void Reset() { Answer.Clear(); Console.WriteLine(SearchQuery); ISearchImplBase search = new ArtyomSearch(); switch (SelectedName) { case "Artyom": break; case "Sergey": search = new SergeySearch(); break; case "Nikita": search = new NikitaSearch(); break; } search.Initialize(); foreach (var k in Directory.EnumerateFiles(ArtyomSearch.RootDirectory, "*.txt")) { if (k != "MyDictionary.txt") { search.AddFileToIndex(k); } } if (SearchQuery == "") { return; } foreach (var inner in search.DoSearch(SearchQuery)) { Answer.Add($"{Path.GetFileName(inner.FilePath)} : {inner.Score}"); } }
private static void Main(string[] args) { var iStdOut = GetStdHandle(STD_OUTPUT_HANDLE); if (!GetConsoleMode(iStdOut, out uint outConsoleMode)) { Console.WriteLine("failed to get output console mode"); Console.ReadKey(); return; } outConsoleMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING | DISABLE_NEWLINE_AUTO_RETURN; if (!SetConsoleMode(iStdOut, outConsoleMode)) { Console.WriteLine($"failed to set output console mode, error code: {GetLastError()}"); Console.ReadKey(); return; } Console.WriteLine("Выберите реализацию которую хотите увидеть"); Console.WriteLine(" 1)Артем"); Console.WriteLine(" 2)Никита"); Console.WriteLine(" 3)Сергей"); ConsoleKeyInfo searchKey = Console.ReadKey(); Console.WriteLine(); ISearchImplBase engine; switch (searchKey.KeyChar) { case '1': { engine = new ArtyomSearch(); break; } case '3': { engine = new SergeySearch(); break; } default: { engine = new NikitaSearch(); break; } } engine.Initialize(); foreach (var filePath in AddFile()) { engine.AddFileToIndex(filePath); } string inputText = File.ReadAllText(Path.Combine(NikitaSearch.DataDirectory, "vvod.txt")); foreach (var lines in engine.DoSearch(inputText)) { //Console.WriteLine(lines); if (lines.Score != 0) { Console.Write("\u001b[1;33m>>> \u001b[0m"); Console.Write("\u001b[1;37m"); Console.Write(lines.FilePath); Console.WriteLine("\u001b[0m"); Console.WriteLine(" " + lines.BestContentExtract); Console.WriteLine(); Console.WriteLine(); } } #if false Console.WriteLine("░░░░░░░█▐▓▓░████▄▄▄█▀▄▓▓▓▌█"); Console.WriteLine("░░░░░▄█▌▀▄▓▓▄▄▄▄▀▀▀▄▓▓▓▓▓▌█"); Console.WriteLine("░░░▄█▀▀▄▓█▓▓▓▓▓▓▓▓▓▓▓▓▀░▓▌█ "); Console.WriteLine("░░█▀▄▓▓▓███▓▓▓███▓▓▓▄░░▄▓▐█▌ "); Console.WriteLine("░█▌▓▓▓▀▀▓▓▓▓███▓▓▓▓▓▓▓▄▀▓▓▐█ "); Console.WriteLine("▐█▐██▐░▄▓▓▓▓▓▀▄░▀▓▓▓▓▓▓▓▓▓▌█▌"); Console.WriteLine("█▌███▓▓▓▓▓▓▓▓▐░░▄▓▓███▓▓▓▄▀▐█"); Console.WriteLine("█▐█▓▀░░▀▓▓▓▓▓▓▓▓▓██████▓▓▓▓▐█"); Console.WriteLine("▌▓▄▌▀░▀░▐▀█▄▓▓██████████▓▓▓▌█▌"); Console.WriteLine("▌▓▓▓▄▄▀▀▓▓▓▀▓▓▓▓▓▓▓▓█▓█▓█▓▓▌█▌"); Console.WriteLine("█▐▓▓▓▓▓▓▄▄▄▓▓▓▓▓▓█▓█▓█▓█▓▓▓▐█"); #endif Console.ReadLine(); }