コード例 #1
0
        public IEnumerable <IWord> Match(IEnumerable <string> words, bool wholeWord)
        {
            IEnumerable <IWord> matches;

            if (wholeWord)
            {
                matches = WeightedWords.Where(a => words.Any(x => x.Equals(a.Text, StringComparison.CurrentCultureIgnoreCase)));
            }
            else
            {
                matches = WeightedWords.Where(a => words.Any(x => (a.Text.IndexOf(x, StringComparison.CurrentCultureIgnoreCase) == 0)));
            }

            return(matches.SortByOccurrences());
        }
コード例 #2
0
        public bool Match(string word)
        {
            if (word == null)
            {
                return(false);
            }

            if (WeightedWords.Count() == 0)
            {
                return(false);
            }

            var matches = WeightedWords.Where(x => word.Equals(x.Text, StringComparison.CurrentCultureIgnoreCase));

            return(matches != null);
        }