// Listing 2.23 Fast Fuzzy Match using precomputation public static Func <string, string> PartialFuzzyMatch(List <string> words) //#A { var wordSet = new HashSet <string>(words); //#B return(word => (from w in wordSet.AsParallel() select JaroWinklerModule.Match(w, word)) .OrderByDescending(w => w.Distance) .Select(w => w.Word) .FirstOrDefault()); //#C }
// Listing 2.22 A fuzzy match public static string FuzzyMatch(List <string> words, string word) { var wordSet = new HashSet <string>(words); //#A string bestMatch = (from w in wordSet.AsParallel() //#B select JaroWinklerModule.Match(w, word)) .OrderByDescending(w => w.Distance) .Select(w => w.Word) .FirstOrDefault(); return(bestMatch); //#C }