// Add new Key / Value to a existing Dictionary public Dictionary <string, string> Add(Dictionary <string, string> dictionary, string key, string value) { value = Porter.Stem(value).Value; key = Porter.Stem(key).Value; //Console.WriteLine(value); if (!dictionary.ContainsKey(key)) { dictionary.Add(key, value); } return(dictionary); }
public string[] StemWordList(string[] wordlist) { string[] copyArray = wordlist.ToArray(); for (int i = 0; i < copyArray.Length; i++) { string StemValue = Porter.Stem(copyArray[i]).Value; copyArray[i] = StemValue; } return(copyArray); }
public bool LoadMendatoryWords(string line) { try { string[] topics = line.Split(new char[] { ',' }, line.Length, StringSplitOptions.RemoveEmptyEntries); Topic tempTopic; foreach (string topic in topics) { if (topic[0] == '[' && topic[topic.Length - 1] == ']') { string[] tempTopicKeywords = topic.Substring(1, topic.Length - 2).Split(new char[] { ' ' }, topic.Length, StringSplitOptions.RemoveEmptyEntries); TotalKeywords += tempTopicKeywords.Length; tempTopic = new Topic(); for (int ind = 0; ind < tempTopicKeywords.Length; ind++) { tempTopic.AddTopic( _stemmer.Stem( tempTopicKeywords[ind] .Replace("@", "") .Replace("#", "") .ToLower() ).Value ); } ActualTopicList.Add(tempTopic); } else { throw new Exception("The topic is not in proper format"); } } return(true); } catch (Exception ex) { throw ex; } }