Esempio n. 1
0
 public void TestJaccardSimilarityWithDifferentValues()
 {
     Assert.AreEqual(4 / (decimal)5, Similarity.CalculateJaccardSimilarity("test1", "test2").Value);
     Assert.AreEqual(0, Similarity.CalculateJaccardSimilarity("test", string.Empty).Value);
     Assert.AreEqual(0, Similarity.CalculateJaccardSimilarity(string.Empty, "test").Value);
     Assert.AreEqual(0, Similarity.CalculateJaccardSimilarity("test", "a").Value);
     Assert.AreEqual(0, Similarity.CalculateJaccardSimilarity("a", "test").Value);
     Assert.AreEqual((decimal)1 / 4, Similarity.CalculateJaccardSimilarity("test", "aeaa").Value);
     Assert.AreEqual((decimal)1 / 4, Similarity.CalculateJaccardSimilarity("aeaa", "test").Value);
     Assert.AreEqual(0, Similarity.CalculateJaccardSimilarity("abcd", "efgh").Value);
     Assert.AreEqual((decimal)3 / 8, Similarity.CalculateJaccardSimilarity("xx345xxx", "yy345yyy").Value);
     Assert.AreEqual((decimal)5 / 8, Similarity.CalculateJaccardSimilarity("12xxx678", "12yyy678").Value);
 }
Esempio n. 2
0
 public void TestJaccardIndexSimilarityWithCompletelyDifferentStrings()
 {
     Assert.AreEqual(0, Similarity.CalculateJaccardSimilarity("abcd", "efgh").Value);
 }
Esempio n. 3
0
        public void TestCalculateJaccardSimilarityWithEqualStrings()
        {
            string testString = "test";

            Assert.AreEqual(1, Similarity.CalculateJaccardSimilarity(testString, testString).Value);
        }