public static Dictionary <string, List <(string league, string link)> > GetSportHierarchy(string html) { sw.Start(); var out_uuid = FileSupervisor.WriteFile(html); Console.WriteLine($"Write html to files: {sw.ElapsedMilliseconds}ms"); sw.Restart(); ScriptRunner scrunner = new ScriptRunner(Assembly.GetExecutingAssembly()); string in_uuid = scrunner.RunScript("sport_hierarchy.py", out_uuid).Trim(); Console.WriteLine($"Python time: {sw.ElapsedMilliseconds}ms"); sw.Restart(); string data = FileSupervisor.ReadFile(in_uuid); Console.WriteLine($"Read results: {sw.ElapsedMilliseconds}ms"); sw.Restart(); var sportHierarchy = new Dictionary <string, List <(string, string)> >(); foreach (var pair in SerializationSupervisor.Deserialize <Dictionary <string, List <object[]> > >(data)) { sportHierarchy.Add(pair.Key, pair.Value.Select(x => (x[0] as string, x[1] as string)).ToList()); } FileSupervisor.DeleteFile(out_uuid); FileSupervisor.DeleteFile(in_uuid); Console.WriteLine($"Delete files: {sw.ElapsedMilliseconds}ms"); return(sportHierarchy); }
/// <summary> /// Creates new search engine instance /// </summary> /// <param name="settings">Engine settings object</param> /// <returns>New search engine instance</returns> public static ISearchEngine New(SearchEngineSettings settings) { if (settings == null) { throw new ArgumentNullException(nameof(settings)); } var eventReactor = new EventReactor(); var fileParserProvider = new FileParserProvider(settings); var filesVersionsRegistry = new FilesVersionsRegistry(); var index = new Index.Index(); var indexer = new FileIndexer(eventReactor, fileParserProvider, index, filesVersionsRegistry, settings); var indexEjector = new IndexEjector(eventReactor, filesVersionsRegistry); var indexUpdater = new IndexUpdater(eventReactor, indexer, filesVersionsRegistry); var watchersCollection = new PathWatchersCollection(); var fileSupervisor = new FileSupervisor( eventReactor, new FileSystemEventsProcessor( new FileSystemEventHandler( new CreateEventHandler(indexer), new ChangeEventHandler(indexUpdater), new DeleteEventHandler(eventReactor, indexEjector, watchersCollection), new RenameEventHandler( eventReactor, new FilePathActualizer(filesVersionsRegistry), watchersCollection ) ) ), watchersCollection, new PathPoller( new DeadPathDetector( watchersCollection, new PathRemover(eventReactor, watchersCollection, indexEjector) ), watchersCollection ) ); var searcher = new Searcher(index); var indexCleaner = new IndexCleaner(eventReactor, index, filesVersionsRegistry, settings); var scheduler = new Scheduler(indexCleaner, settings); return(new SearchEngine(eventReactor, indexer, indexEjector, fileSupervisor, searcher, scheduler)); }