public void PossibleWordsFromUncertainties_1x0() { _entry["Phonetic"] = "(1/2)n"; _results = _entry.GetAllPossibleUncertainWords(false); Assert.AreEqual(2, _results.Length); Assert.AreEqual("1", _results[0][0]); Assert.AreEqual("n", _results[0][1]); Assert.AreEqual("2", _results[1][0]); Assert.AreEqual("n", _results[1][1]); }
/// ------------------------------------------------------------------------------------ public bool MatchesSearchPattern(WordCacheEntry entry) { if (m_searchQuery == null || string.IsNullOrEmpty(m_pattern)) { return(false); } string[][] eticWords = new string[1][]; if (m_searchQuery.IncludeAllUncertainPossibilities && entry.ContiansUncertainties) { // Get a list of all the words (each word being in the form of // an array of phones) that can be derived from all the primary // and non primary uncertainties. eticWords = entry.GetAllPossibleUncertainWords(false); if (eticWords == null) { return(false); } } else { // Not all uncertain possibilities should be included in the search, so // just load up the phones that only include the primary uncertain Phone(s). eticWords[0] = entry.Phones; if (eticWords[0] == null) { return(false); } } // If eticWords.Length = 1 then either the word we're searching doesn't contain // uncertain phones or it does but they are only primary uncertain phones. When // eticWords.Length > 1, we know the uncertain phones in the first word are only // primary uncertainities while at least one phone in the remaining words is a // non primary uncertainy. for (int i = 0; i < eticWords.Length; i++) { // If the search pattern contains the word breaking character, then add a // space at the beginning and end of the array of phones so the word breaking // character has something to match at the extremes of the phonetic values. if (m_patternContainsWordBoundaries) { List <string> tmpChars = new List <string>(eticWords[i]); tmpChars.Insert(0, " "); tmpChars.Add(" "); eticWords[i] = tmpChars.ToArray(); } int[] result; if (SearchEngine.SearchWord(eticWords[i], out result)) { return(true); } } return(false); }