public void BuildKnowledges() { #region UI this.Cursor = Cursors.WaitCursor; StatusLabel1.Text = Messages.InitializingDictionaries; #endregion if (!IsInited) { //Need to implement IsInited in new option handlers! ShortcutManager.Instance.Init(ConfigurationManager.GetSection("shortcutManager")); ClauseHolderManager.Instance.Init(ConfigurationManager.GetSection("clauseHolderManager")); WordHolderManager.Instance.Init(ConfigurationManager.GetSection("wordHolderManager")); EntityTemplateManager.GetInstance().Init(ConfigurationManager.GetSection("entityTemplateManager")); //Init dictionaries if (!DictionaryManager.GetInstance().IsInited) { DictionaryManager.GetInstance().Init((DictionaryManagerOptions)ConfigurationManager.GetSection("dictionaryManager")); } IsInited = true; } #region UI DateTime startDT = DateTime.Now; #endregion //Reading file #region UI StatusLabel1.Text = Messages.ReadingSource; #endregion Provider <IDocumentProvider> documentProviderProvider = _DocumentProviderConfig[cbDocumentProviderProvider.Text]; IDocumentProvider documentProvider = documentProviderProvider.CreateProvidedClassInstance(); documentProvider.Init(txtDocumentsProviderSettings.Text); //Graph EntityGraph entityGraph; if (cbLoadFromDump.Checked) { try { entityGraph = EntityGraph.LoadDump(txtLoadFromDumpFileName.Text); } catch { if (DialogResult.OK == MessageBox.Show("Ignore?", "Cannot load dump", MessageBoxButtons.OKCancel, MessageBoxIcon.Question)) { entityGraph = new EntityGraph(); } else { return; } } } else { entityGraph = new EntityGraph(); } foreach (IDocument document in documentProvider) { foreach (IArticle article in document) { //Prospecting #region UI StatusLabel1.Text = Messages.Translating; #endregion IProspector prospector = ProspectorManager.Instance.GetProspector(article); prospector.Prospect(entityGraph, article); } document.Close(); } documentProvider.Close(); //Optimizing the graph #region UI StatusLabel1.Text = Messages.OptimizingGraph; #endregion EntityGraphOptimizer entityGraphOptimizer = new EntityGraphOptimizer(entityGraph); entityGraphOptimizer.OptimizeSubclassRelationship(); entityGraphOptimizer.OptimizePropertyRelationships(); //Saving Graph to file #region UI StatusLabel1.Text = Messages.SavingGraph; #endregion Provider <IOntology> outputOntologyProvider = _OnologyConfig[cbOutputOntologyProvider.Text]; IOntology outputOntology = outputOntologyProvider.CreateProvidedClassInstance(); outputOntology.SaveGraph(entityGraph, txtOutputFileName.Text); if (cbAddToDump.Checked) { entityGraph.Dump(txtAddToDumpFileName.Text); } #region UI DateTime stopDT = DateTime.Now; TimeSpan ts = stopDT - startDT; StatusLabel1.Text = string.Format(Messages.BuildingCompliteFormat, ts.TotalMilliseconds); StatusProgressBar1.Visible = false; this.Cursor = Cursors.Default; MessageBox.Show(string.Format("Done by {0} milliseconds", ts.TotalMilliseconds), "Knowledge Prospector", MessageBoxButtons.OK, MessageBoxIcon.Information); #endregion GC.Collect(); }