Esempio n. 1
0
 public void TestLevenshteinSimilarityWithDifferentValues()
 {
     Assert.AreEqual((decimal)4 / 5, Similarity.CalculateLevenshteinSimilarity("test", "test2").Value);
     Assert.AreEqual((decimal)4 / 5, Similarity.CalculateLevenshteinSimilarity("test1", "test2").Value);
     Assert.AreEqual(0, Similarity.CalculateLevenshteinSimilarity("test", string.Empty).Value);
     Assert.AreEqual(0, Similarity.CalculateLevenshteinSimilarity(string.Empty, "test").Value);
     Assert.AreEqual(0, Similarity.CalculateLevenshteinSimilarity("test", "a").Value);
     Assert.AreEqual(0, Similarity.CalculateLevenshteinSimilarity("a", "test").Value);
     Assert.AreEqual((decimal)1 / 4, Similarity.CalculateLevenshteinSimilarity("test", "aeaa").Value);
     Assert.AreEqual((decimal)1 / 4, Similarity.CalculateLevenshteinSimilarity("aeaa", "test").Value);
     Assert.AreEqual(0, Similarity.CalculateLevenshteinSimilarity("abcd", "efgh").Value);
     Assert.AreEqual((decimal)3 / 8, Similarity.CalculateLevenshteinSimilarity("xx345xxx", "yy345yyy").Value);
     Assert.AreEqual((decimal)5 / 8, Similarity.CalculateLevenshteinSimilarity("12xxx678", "12yyy678").Value);
     Assert.AreEqual((decimal)7 / 10, Similarity.CalculateLevenshteinSimilarity("12345678", "1x34567890").Value);
 }
Esempio n. 2
0
        public void TestLevenshteinSimilarityWithEqualStrings()
        {
            string testString = "test";

            Assert.AreEqual(1, Similarity.CalculateLevenshteinSimilarity(testString, testString).Value);
        }
Esempio n. 3
0
 public void TestLevenshteinSimilarityWithCompletelyDifferentStrings()
 {
     Assert.AreEqual(0, Similarity.CalculateLevenshteinSimilarity("abcd", "efgh").Value);
 }