/// <summary> /// Searches all contained word lists for word /// </summary> /// <param name="word" type="string"> /// <para> /// The word to search for /// </para> /// </param> /// <returns> /// Returns true if word is found /// </returns> public bool Contains(string word) { // clean up possible base word list PossibleBaseWords.Clear(); // Step 1 Search UserWords if (UserWords.ContainsKey(word)) { TraceWriter.TraceVerbose("Word Found in User Dictionary: {0}", word); return(true); // word found } // Step 2 Search BaseWords if (BaseWords.ContainsKey(word)) { TraceWriter.TraceVerbose("Word Found in Base Words: {0}", word); return(true); // word found } // Step 3 Remove suffix, Search BaseWords // save suffixed words for use when removing prefix List <string> suffixWords = new List <string>(); // Add word to suffix word list suffixWords.Add(word); foreach (AffixRule rule in SuffixRules.Values) { foreach (AffixEntry entry in rule.AffixEntries) { string tempWord = AffixUtility.RemoveSuffix(word, entry); if (tempWord != word) { if (BaseWords.ContainsKey(tempWord)) { if (VerifyAffixKey(tempWord, rule.Name[0])) { TraceWriter.TraceVerbose("Word Found With Base Words: {0}; Suffix Key: {1}", tempWord, rule.Name[0]); return(true); // word found } } if (rule.AllowCombine) { // saving word to check if it is a word after prefix is removed suffixWords.Add(tempWord); } else { // saving possible base words for use in generating suggestions PossibleBaseWords.Add(tempWord); } } } } // saving possible base words for use in generating suggestions PossibleBaseWords.AddRange(suffixWords); // Step 4 Remove Prefix, Search BaseWords foreach (AffixRule rule in PrefixRules.Values) { foreach (AffixEntry entry in rule.AffixEntries) { foreach (string suffixWord in suffixWords) { string tempWord = AffixUtility.RemovePrefix(suffixWord, entry); if (tempWord != suffixWord) { if (BaseWords.ContainsKey(tempWord)) { if (VerifyAffixKey(tempWord, rule.Name[0])) { TraceWriter.TraceVerbose("Word Found With Base Words: {0}; Prefix Key: {1}", tempWord, rule.Name[0]); return(true); // word found } } // saving possible base words for use in generating suggestions PossibleBaseWords.Add(tempWord); } } // suffix word } // prefix rule entry } // prefix rule // word not found TraceWriter.TraceVerbose("Possible Base Words: {0}", PossibleBaseWords.Count); return(false); }