public void WordLevensteinAlgorithm_ShouldWork_CustomCharacterSimiarityResolver() { var resolver = new CharacterSimilarityResolverDefault(null, StringComparisonOptions.CaseSensitive); resolver.SetMistakeSimilarity('m', 'n', 0.8f); resolver.SetMistakeSimilarity('o', 'u', 0.7f); resolver.SetMistakeSimilarity('i', 'y', 0.8f); resolver.SetMistakeSimilarity('c', 'k', 0.6f); resolver.SetMistakeSimilarity('X', 'A', 0.9f); var algorithm = new LevensteinAlgorithm <Word, char>(resolver); AreSimilar(algorithm, "XXXXX", "AAAAA"); NotSimilar(algorithm, "xxxxx", "aaaaa"); AreSimilar(algorithm, "Mehran", "Nehran"); NotSimilar(algorithm, "MEHRAN", "mehran"); AreSimilar(algorithm, "Afshin", "Aphshin"); AreSimilar(algorithm, "Mehran", "Nahran"); AreSimilar(algorithm, "Monica", "Monika"); AreSimilar(algorithm, "Nonica", "Nomika"); AreSimilar(algorithm, "Crespo", "Krespo"); NotSimilar(algorithm, "Mehran", "RamMeh"); NotSimilar(algorithm, "Penalty", "People"); AreSimilar(algorithm, "Monica", "Numyka"); NotSimilar(algorithm, "Monica", "NUmYkA"); }
public void WordLevensteinAlgorithm_ShouldWork_CustomCharacterSimiarityResolver_NotCaseSensitive() { var resolver = new CharacterSimilarityResolverDefault(null, StringComparisonOptions.None); resolver.SetMistakeSimilarity('m', 'n', 0.8f); resolver.SetMistakeSimilarity('o', 'u', 0.7f); resolver.SetMistakeSimilarity('i', 'y', 0.8f); resolver.SetMistakeSimilarity('c', 'k', 0.6f); resolver.SetMistakeSimilarity('X', 'A', 0.9f); var algorithm = new LevensteinAlgorithm <Word, char>(resolver); AreSimilar(algorithm, "XXXXX", "AAAAA"); AreSimilar(algorithm, "xxxxx", "aaaaa"); AreSimilar(algorithm, "Monica", "Numyka"); AreSimilar(algorithm, "Monica", "NUmYkA"); }
public void CharacterMistakeBased_ShouldWork_DefinedMistakes_NotCaseSensitive() { var simila = new CharacterSimilarityResolverDefault(null, StringComparisonOptions.None); simila.SetMistakeSimilarity('c', 'k', 0.7f); Assert.AreEqual(0, simila.GetSimilarity('a', 'b')); Assert.AreEqual(0, simila.GetSimilarity('a', 'B')); Assert.AreEqual(0.7f, simila.GetSimilarity('c', 'k')); Assert.AreEqual(0.7f, simila.GetSimilarity('k', 'c')); Assert.AreEqual(0.7f, simila.GetSimilarity('c', 'K')); Assert.AreEqual(0.7f, simila.GetSimilarity('K', 'c')); Assert.AreEqual(0.7f, simila.GetSimilarity('C', 'k')); Assert.AreEqual(0.7f, simila.GetSimilarity('k', 'C')); }