public MatchResult FuzzyMatch(string query, string stringToCompare) { query = query.Trim(); if (string.IsNullOrEmpty(stringToCompare) || string.IsNullOrEmpty(query)) { return(new MatchResult(false, UserSettingSearchPrecision)); } var queryWithoutCase = query.ToLower(); var translated = _alphabet.Translate(stringToCompare); var key = $"{queryWithoutCase}|{translated}"; var match = _cache[key] as MatchResult; if (match == null) { match = FuzzyMatchRecursive( queryWithoutCase, translated, 0, 0, new List <int>() ); var policy = new CacheItemPolicy(); policy.SlidingExpiration = new TimeSpan(12, 0, 0); _cache.Set(key, match, policy); } return(match); }
public MatchResult FuzzyMatch(string query, string stringToCompare) { query = query.Trim(); if (string.IsNullOrEmpty(stringToCompare) || string.IsNullOrEmpty(query)) { return(new MatchResult(false, UserSettingSearchPrecision)); } var queryWithoutCase = query.ToLower(); string translated = _alphabet.Translate(stringToCompare); var fullStringToCompareWithoutCase = translated.ToLower(); string key = $"{queryWithoutCase}|{fullStringToCompareWithoutCase}"; MatchResult match = _cache[key] as MatchResult; if (match == null) { match = FuzzyMatchInternal(queryWithoutCase, fullStringToCompareWithoutCase); CacheItemPolicy policy = new CacheItemPolicy(); policy.SlidingExpiration = new TimeSpan(12, 0, 0); _cache.Set(key, match, policy); } return(match); }