/// <summary> /// Gets the relevant terms. /// </summary> /// <param name="text">The text.</param> /// <returns> /// IDictionary of types of tokens and values /// </returns> IDictionary<string, IEnumerable<string>> INlpProvider.GetRelevantTerms(string text) { IDictionary<string, IEnumerable<string>> returnDictionary = new Dictionary<string, IEnumerable<string>>(); var annotation = new Annotation(text); NlpProvider.pipeline.annotate(annotation); var sentences = annotation.get(new CoreAnnotations.SentencesAnnotation().getClass()) as ArrayList; foreach (CoreMap sentence in sentences) { var tokens = sentence.get(new CoreAnnotations.TokensAnnotation().getClass()) as ArrayList; foreach (CoreLabel token in tokens) { string pos = token.get(new CoreAnnotations.PartOfSpeechAnnotation().getClass()).ToString().ToUpper(); if (NlpProvider.relevantPos.Contains(pos)) { List<string> listOfValues; if (returnDictionary.ContainsKey(pos)) { listOfValues = returnDictionary[pos] as List<string>; } else { listOfValues = new List<string>(); returnDictionary.Add(pos, listOfValues); } string word = token.get(new CoreAnnotations.TextAnnotation().getClass()).ToString(); listOfValues.Add(word); ////var ner = token.get(new CoreAnnotations.NamedEntityTagAnnotation().getClass()); ////var normalizedner = token.get(new CoreAnnotations.NormalizedNamedEntityTagAnnotation().getClass()); } } } return returnDictionary; }
public bool GenerateForAllUsedIncomplete() { var allAssemblyTypes = new Dictionary<string, Type>(); foreach (Type t in TargetAssembly.GetTypes().Where(t => t.IsPublic)) { if (!allAssemblyTypes.ContainsKey(t.Name)) allAssemblyTypes.Add(t.Name, t); } bool added = false; foreach (Type type in UsedTypes.ToArray()) { if (!TypeIsWrapped(type)) throw new InvalidOperationException(); if (!CompleteTypes.ContainsKey(type)) { var wci = new WrapperClassInfo(type, this); CompleteTypes.Add(type, wci); foreach ( Type inheritedType in allAssemblyTypes.Values.Where(t => t.IsSubclassOf(wci.WrappedType) && t.IsPublic) .Where(TypeIsWrapped)) { if (inheritedType.GetCustomAttributes(typeof(ObsoleteAttribute), true).Count() == 0 && !UsedTypes.Contains(inheritedType)) UsedTypes.Add(inheritedType); } var sb = new StringBuilder(); if (wci.IsInterface) wci.GenerateInterfaceCode(sb); else wci.GenerateClassCode(sb); if (wci.FilePathBase.IndexOfAny(new[] { '\\', '/' }) != -1) Directory.CreateDirectory(Path.GetDirectoryName(wci.FilePathBase)); WriteTextToFile(wci.FilePathBase + ".cs", sb.ToString(), true); wci.GenerateUserClassFile(); added = true; } } return added; }