示例#1
0
 public void Test_Perf2()
 {
     for (int i = 1; i < 10000; i++)
     {
         IndistinctMatching.LevenshteinDistance("Ivanvo", "Ivanov");
         IndistinctMatching.DamerauLevenshteinDistance("Ivanvo", "Ivanov");
     }
 }
示例#2
0
        public void Test_Common()
        {
            int res1, res2;

            res1 = IndistinctMatching.LevenshteinDistance("", "");
            Assert.AreEqual(0, res1);
            res1 = IndistinctMatching.LevenshteinDistance("Ivanov", "");
            Assert.AreEqual(6, res1);
            res1 = IndistinctMatching.LevenshteinDistance("", "Petroff");
            Assert.AreEqual(7, res1);
            res1 = IndistinctMatching.LevenshteinDistance("Ivanov", "Ivanov");
            Assert.AreEqual(0, res1);
            res1 = IndistinctMatching.LevenshteinDistance("Ivanov", "IvanovTest");
            Assert.AreEqual(4, res1);
            res1 = IndistinctMatching.LevenshteinDistance("Ivanvo", "Ivanov");
            Assert.AreEqual(2, res1);
            res1 = IndistinctMatching.LevenshteinDistance("Petroff", "Pterov");
            Assert.AreEqual(4, res1); // permutation -fail

            res1 = IndistinctMatching.DamerauLevenshteinDistance("", "");
            Assert.AreEqual(0, res1);
            res1 = IndistinctMatching.DamerauLevenshteinDistance("Ivanov", "");
            Assert.AreEqual(6, res1);
            res1 = IndistinctMatching.DamerauLevenshteinDistance("", "Petroff");
            Assert.AreEqual(7, res1);
            res2 = IndistinctMatching.DamerauLevenshteinDistance("Ivanov", "Ivanov");
            Assert.AreEqual(0, res2);
            res1 = IndistinctMatching.DamerauLevenshteinDistance("Ivanov", "IvanovTest");
            Assert.AreEqual(4, res1);
            res2 = IndistinctMatching.DamerauLevenshteinDistance("Ivanvo", "Ivanov");
            Assert.AreEqual(1, res2);
            res1 = IndistinctMatching.DamerauLevenshteinDistance("Petroff", "Pterov");
            Assert.AreEqual(3, res1); // permutation -ok

            Assert.Throws(typeof(ArgumentNullException), () => { IndistinctMatching.GetSimilarity("Ivanvo", null); });
            Assert.Throws(typeof(ArgumentNullException), () => { IndistinctMatching.GetSimilarity(null, "Ivanov"); });

            Assert.GreaterOrEqual(IndistinctMatching.GetSimilarity("Ivanov", "Ivanov"), 1.0f);
            Assert.GreaterOrEqual(IndistinctMatching.GetSimilarity("Ivanvo", "Ivanov"), 0.833f);
        }