// ---------------------------------------------------------------------------------------- /// <!-- ExtractProperNouns --> /// <summary> /// /// </summary> /// <param name="WordTally"></param> /// <param name="RegularWord"></param> /// <returns></returns> /// <remarks>relies on RegularWord and WordTally</remarks> private Dictionary <string, int> ExtractProperNouns() { // Resolve a list of keys Dictionary <string, int> proper = new Dictionary <string, int>(); List <string> keys = WordTally.Keys.ToList(); foreach (string word in keys) { if (WordTally[word] > 0) { string lower = word.ToLower(); if (RegularWord.ContainsKey(lower)) { RegularWord[lower] += WordTally[word]; } else { proper.Add(word, WordTally[word]); } WordTally[word] = 0; } } return(proper); }
// ---------------------------------------------------------------------------------------- /// <!-- OrderWordsByValue --> /// <summary> /// /// </summary> /// <param name="text"></param> /// <returns></returns> public List <string> OrderWordsByValue(string text) { string[] textWords = text.Split(CommonSplitter.ToCharArray()); Dictionary <string, int> local = new Dictionary <string, int>(); for (int i = 0; i < textWords.Length; ++i) { string textWord = textWords[i]; if (!local.ContainsKey(textWord) && RegularWord.ContainsKey(textWord)) { local.Add(textWord, RegularWord[textWord]); } } List <string> sorted = (from item in local orderby item.Value select item.Key).ToList <string>(); return(sorted); }