예제 #1
0
        /// ------------------------------------------------------------------------------------
        public bool Search(bool returnCountOnly, out int resultCount)
        {
            ResultCache = (returnCountOnly ? null : new WordListCache());
            resultCount = 0;

            foreach (var wentry in _project.WordCache)
            {
                if (ReportProgressAction != null)
                {
                    ReportProgressAction();
                }

                // Get a list of word(s) for this entry. If the query's IncludeAllUncertainPossibilities
                // flag is set, there will be multiple words, one for each uncertain possibility.
                // Otherwise there will be only one. Each word is delivered in the form of an array of
                // phones.
                var wordsList = (_query.IncludeAllUncertainPossibilities && wentry.ContiansUncertainties ?
                                 wentry.GetAllPossibleUncertainWords(false) : new[] { wentry.Phones });

                foreach (var phonesInWord in wordsList)
                {
                    resultCount = SearchWord(phonesInWord, returnCountOnly,
                                             (phoneIndexOfMatch, numberOfPhonesInMatch) =>
                                             ResultCache.Add(wentry, phonesInWord, phoneIndexOfMatch, numberOfPhonesInMatch, true));
                }
            }

            return(true);
        }