Пример #1
0
        public void GetSimilarityTest()
        {
            // addition edit distance test
            const string addFirst  = "abcd";
            const string addSecond = "abcdx";

            SimilarityHelpers.SimilarityInterfaceTest(_diceCoefUnigram, addFirst, addSecond, GetExpectedDiceCoefficient(4, 4, 5));
            SimilarityHelpers.SimilarityInterfaceTest(_diceCoefBigram, addFirst, addSecond, GetExpectedDiceCoefficient(3, 3, 4));
            SimilarityHelpers.SimilarityInterfaceTest(_diceCoefTrigram, addFirst, addSecond, GetExpectedDiceCoefficient(2, 2, 3));

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

            SimilarityHelpers.SimilarityInterfaceTest(_diceCoefUnigram, delFirst, delSecond, GetExpectedDiceCoefficient(3, 4, 3));
            SimilarityHelpers.SimilarityInterfaceTest(_diceCoefBigram, delFirst, delSecond, GetExpectedDiceCoefficient(2, 3, 2));
            SimilarityHelpers.SimilarityInterfaceTest(_diceCoefTrigram, delFirst, delSecond, GetExpectedDiceCoefficient(1, 2, 1));

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

            SimilarityHelpers.SimilarityInterfaceTest(_diceCoefUnigram, subFirst, subSecond, GetExpectedDiceCoefficient(3, 4, 4));
            SimilarityHelpers.SimilarityInterfaceTest(_diceCoefBigram, subFirst, subSecond, GetExpectedDiceCoefficient(1, 3, 3));
            SimilarityHelpers.SimilarityInterfaceTest(_diceCoefTrigram, subFirst, subSecond, GetExpectedDiceCoefficient(0, 2, 2));

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

            SimilarityHelpers.SimilarityInterfaceTest(_diceCoefUnigram, mixFirst, mixSecond, GetExpectedDiceCoefficient(6, 7, 6));
            SimilarityHelpers.SimilarityInterfaceTest(_diceCoefBigram, mixFirst, mixSecond, GetExpectedDiceCoefficient(4, 6, 5));
            SimilarityHelpers.SimilarityInterfaceTest(_diceCoefTrigram, mixFirst, mixSecond, GetExpectedDiceCoefficient(3, 5, 4));
        }
        public void GetSimilarityTest()
        {
            // addition edit distance test
            const string addFirst  = "abcd";
            const string addSecond = "abcdx";

            SimilarityHelpers.SimilarityInterfaceTest(_damerauLevenshtein, addFirst, addSecond, 0.8);

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

            SimilarityHelpers.SimilarityInterfaceTest(_damerauLevenshtein, delFirst, delSecond, 0.75);

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

            SimilarityHelpers.SimilarityInterfaceTest(_damerauLevenshtein, subFirst, subSecond, 0.75);

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

            SimilarityHelpers.SimilarityInterfaceTest(_damerauLevenshtein, mixFirst, mixSecond, 0.714);

            // transposition
            const string transFirst  = "abcd";
            const string transSecond = "acbd";

            SimilarityHelpers.SimilarityInterfaceTest(_damerauLevenshtein, transFirst, transSecond, 0.75);
        }
Пример #3
0
        public void GetSimilarityTest()
        {
            // addition edit distance test
            const string addFirst  = "abcd";
            const string addSecond = "abcdx";

            SimilarityHelpers.SimilarityInterfaceTest(_jaroWinkler, addFirst, addSecond, 0.960);

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

            SimilarityHelpers.SimilarityInterfaceTest(_jaroWinkler, delFirst, delSecond, 0.942);

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

            SimilarityHelpers.SimilarityInterfaceTest(_jaroWinkler, subFirst, subSecond, 0.850);

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

            SimilarityHelpers.SimilarityInterfaceTest(_jaroWinkler, mixFirst, mixSecond, 0.849);
        }
Пример #4
0
        public void RealCasesTest()
        {
            // test from wikipedia
            const string wikiFirst  = "martha";
            const string wikiSecond = "marhta";

            SimilarityHelpers.SimilarityInterfaceTest(_jaro, wikiFirst, wikiSecond, 0.944);

            //// test from wikipedia
            //const string wiki2First = "dwayne";
            //const string wiki2Second = "duane";
            //SimilarityHelpers.SimilarityInterfaceTest(_jaro, wiki2First, wiki2Second, 0.933);
        }