コード例 #1
0
        private bool IsFuzzyMatch(string word, string searchTerm)
        {
            if (word.Length <= 2)
            {
                // For 1-letter and 2-letter words, we need an exact match (no spelling mistakes)
                return(false);
            }
            else
            {
                // For words of more than 3 letters, allow "length/3" spelling mistakes

                int numberOfSpellingMistakes  = FuzzySearch.GetDamerauLevenshteinDistance(word, searchTerm);
                int allowableSpellingMistakes = word.Length / 3;

                return(numberOfSpellingMistakes <= allowableSpellingMistakes);
            }
        }