public SelectExistingConcept(AnnotationOntology ao, bool showCheckboxes) { _ao = ao; _showCheckboxes = showCheckboxes; InitializeComponent(); this.Load += new EventHandler(SelectExistingConcept_Load); }
/// <summary> /// load concept ids and their labels - either from a file or from the ontology /// </summary> public void InitAnnotationService(string KEUIFolder, string customOntologyFileName = null) { try { _ao = new AnnotationOntology(); _ao.AddEventHandler = AddEvent; if (File.Exists(Path.Combine(KEUIFolder, CustomLemmasFileName))) { List<string> customLemmas = new List<string>(); foreach (string line in File.ReadAllLines(Path.Combine(KEUIFolder, CustomLemmasFileName))) customLemmas.Add(Tokenization.NormalizeText(line)); _ao.LemmaGen.SetCustomLemmas(customLemmas); } else AddEventAndLog("WARNING: No custom lemmas file was found."); string fullPathToOntologyFileName = customOntologyFileName == null ? Path.Combine(KEUIFolder, _ontologyFileName) : customOntologyFileName; if (string.IsNullOrEmpty(fullPathToOntologyFileName) || !File.Exists(fullPathToOntologyFileName)) AddEventAndLog("WARNING: The Alert Ontology file was not found in folder : " + fullPathToOntologyFileName); else LoadAnnotationOntology(fullPathToOntologyFileName); if (File.Exists(Path.Combine(KEUIFolder, IgnoredConceptsFileName))) { AddEventAndLog("Loading ignored concepts..."); foreach (var line in File.ReadAllLines(Path.Combine(KEUIFolder, IgnoredConceptsFileName))) _ao.IgnoreConcept(line); } else AddEventAndLog("WARNING: No ignored labels file was found."); _ao.UpdateSuggestionsDict(); DateTime start = DateTime.Now; AddEvent("Building information sources dictionary..."); foreach (var tagFileInfo in MailData.GetTags(_tagIdSourceCode)) { string fileName = tagFileInfo.TagName; if (fileName.Contains('/')) fileName = fileName.Substring(fileName.LastIndexOf('/') + 1); //if (fileName.Contains('.')) // fileName = fileName.Substring(0, fileName.IndexOf('.')); fileName = GetCleanFileName(fileName); foreach (var tagModuleInfo in MailData.GetTags(tagFileInfo.TagId)) { string moduleName = tagModuleInfo.TagName; moduleName = GetCleanClassName(moduleName); foreach (var tagMethodInfo in MailData.GetTags(tagModuleInfo.TagId)) { string methodName = tagMethodInfo.TagName; int paramCount = GetMethodArgumentCount(methodName); methodName = GetCleanMethodName(methodName); InformationSourcesAddFileAndMethod(fileName, methodName, paramCount, tagMethodInfo.TagIdStr); InformationSourcesAddClassAndMethod(moduleName, methodName, paramCount, tagMethodInfo.TagIdStr); } } } AddEventAndLog("Dictionary built. Time needed: " + (int)(DateTime.Now - start).TotalMilliseconds + " ms"); AddEventAndLog("Initializing annotator finished."); } catch (Exception ex) { AddEvent("Failed to load concepts: " + ex.Message); GenLib.Log.LogService.LogException("Exception while initializing annotation service.", ex); } }