public void When_difference_is_one_char_case_distance_is_one() { var sut = new LevenshteinFuzzyMatch(); sut.Compare("Levenshtein", "levenshtein") .Should().Be(1); sut.Compare("levensHtein", "levenshtein") .Should().Be(1); }
public void When_miss_just_one_char_distance_is_one() { var sut = new LevenshteinFuzzyMatch(); sut.Compare("levenshtein", "levenshtei") .Should().Be(1); sut.Compare("evenshtein", "levenshtein") .Should().Be(1); }
public void Equal_strings_have_distance_zero() { var sut = new LevenshteinFuzzyMatch(); sut.Compare("levenshtein", "levenshtein") .Should().Be(0); }
public override IEnumerable <ResultInfo> Process(IEnumerable <ResultInfo> results) { var fuzzyMatch = new LevenshteinFuzzyMatch(); return (from computed in from result in results select new { result = result, distance = fuzzyMatch.Compare(_settings.Text, result.Description) } where computed.distance >= _settings.MinimumDistance && computed.distance <= _settings.MaximumDistance select computed.result); }