Esempio n. 1
0
        public void GetDistanceTest()
        {
            // addition edit distance test
            const string addFirst  = "abcd";
            const string addSecond = "abcdx";

            SimilarityHelpers.DistanceInterfaceTest(_levenshtein, addFirst, addSecond, 1);


            // deletation edit distance test
            const string delFirst  = "abcd";
            const string delSecond = "abc";

            SimilarityHelpers.DistanceInterfaceTest(_levenshtein, delFirst, delSecond, 1);

            // substitution edit distance test
            const string subFirst  = "abcd";
            const string subSecond = "axcd";

            SimilarityHelpers.DistanceInterfaceTest(_levenshtein, subFirst, subSecond, 1);

            // substitution and deletation together
            const string mixFirst  = "abcdxyz";
            const string mixSecond = "zbcdxy";

            SimilarityHelpers.DistanceInterfaceTest(_levenshtein, mixFirst, mixSecond, 2);
        }
        public void GetDistanceTest()
        {
            // addition edit distance test
            const string addFirst         = "abcd";
            const string addSecond        = "abcdx";
            const int    addResultExpectd = 1;

            SimilarityHelpers.DistanceInterfaceTest(_damerauLevenshtein, addFirst, addSecond, addResultExpectd);

            // deletation edit distance test
            SimilarityHelpers.DistanceInterfaceTest(_damerauLevenshtein, "abcd", "abc", 1);

            // substitution edit distance test
            SimilarityHelpers.DistanceInterfaceTest(_damerauLevenshtein, "abcd", "axcd", 1);

            // substitution and deletation together
            SimilarityHelpers.DistanceInterfaceTest(_damerauLevenshtein, "abcdxyz", "zbcdxy", 2);

            // transposition
            SimilarityHelpers.DistanceInterfaceTest(_damerauLevenshtein, "abcd", "acbd", 1);
            SimilarityHelpers.DistanceInterfaceTest(_damerauLevenshtein, "abcde", "baced", 2);
        }