コード例 #1
0
 def test_dissimilarity(self):
     self.assertAlmostEqual(
         smart_match.dissimilarity('GGTTGACTA', 'TGTTACGG'), 0.6875)
     smart_match.set_params(gap=-2, match=3, mismatch=-3)
     self.assertAlmostEqual(
         smart_match.dissimilarity('GGTTGACTA', 'TGTTACGG'),
         0.7083333333333333)
コード例 #2
0
 def test_dissimilarity(self):
     self.assertAlmostEqual(smart_match.dissimilarity('hello', 'helo'), 0)
     smart_match.set_params(level='term')
     self.assertAlmostEqual(
         float('%.4f' %
               smart_match.dissimilarity('test string1', 'test string2')),
         0.6667)
     self.assertAlmostEqual(
         smart_match.dissimilarity('test', 'test string2'), 0.5000)
     self.assertAlmostEqual(smart_match.dissimilarity('', 'test string2'),
                            1.0000)
     self.assertAlmostEqual(
         smart_match.dissimilarity('aaa bbb ccc ddd', 'aaa bbb ccc eee'),
         0.4000)
     self.assertAlmostEqual(
         smart_match.dissimilarity('aaa bbb ccc ddd aaa bbb ccc ddd',
                                   'aaa bbb ccc eee'), 0.4000)
     self.assertAlmostEqual(smart_match.dissimilarity('a b c d', 'a b c e'),
                            0.4000)
     self.assertAlmostEqual(
         float('%.4f' % smart_match.dissimilarity('a b c d', 'a b e f')),
         0.6667)
     self.assertAlmostEqual(
         smart_match.dissimilarity('a b b c c', 'a b c e f g'), 0.5000)
     self.assertAlmostEqual(
         smart_match.dissimilarity('a b c', 'a b c e f g'), 0.5000)
コード例 #3
0
 def test_dissimilarity(self):
     self.assertAlmostEqual(
         smart_match.dissimilarity(['Hello', 'world'], ['Hero', 'world']),
         0.2)
     smart_match.set_params(method='cos')
     self.assertAlmostEqual(
         smart_match.dissimilarity(['Hello', 'world'], ['Hero', 'world']),
         0.21652664524307963)
コード例 #4
0
 def test_dissimilarity(self):
     self.assertAlmostEqual(
         smart_match.dissimilarity('test', 'test string1'),
         0.42264973081037427)
     smart_match.set_params(level='term')
     self.assertAlmostEqual(
         smart_match.dissimilarity('test', 'test string2'),
         0.29289321881345254)
コード例 #5
0
 def test_dissimilarity(self):
     self.assertAlmostEqual(
         smart_match.dissimilarity('Web Aplications',
                                   'Web Application Development With PHP'),
         0.1333333333333333)
     self.assertAlmostEqual(smart_match.dissimilarity('', 'eee'), 1)
     self.assertAlmostEqual(smart_match.dissimilarity('aaa', 'eee'), 1)
     self.assertAlmostEqual(smart_match.dissimilarity('Healed', 'Help'),
                            0.5)
     self.assertAlmostEqual(smart_match.dissimilarity('Healed', 'Sold'),
                            0.75)
     self.assertAlmostEqual(
         smart_match.dissimilarity('Web Database Applications',
                                   'Web Application Development With PHP'),
         0.504)
     self.assertAlmostEqual(
         smart_match.dissimilarity(
             'Web Database Applications',
             'WebRAD: Building Database Applications on the Web with Visual FoxPro and Web Connection'
         ), 0.12)
     self.assertAlmostEqual(
         smart_match.dissimilarity(
             'Web Database Applications',
             'Structural Assessment: The Role of Large and Full-Scale Testing'
         ), 0.904)
コード例 #6
0
 def test_dissimilarity(self):
     self.assertEqual(smart_match.dissimilarity('hello', 'hero'), 0.4)
     self.assertEqual(smart_match.dissimilarity('hello', 'hero'), 0.4)
     self.assertEqual(float('%.4f' % smart_match.dissimilarity("test string1", "test string2")), 0.0833)
     self.assertEqual(smart_match.dissimilarity("", "test string2"), 1)
     self.assertEqual(smart_match.dissimilarity("aaa bbb ccc ddd", "aaa bbb ccc eee"), 0.2000)
     self.assertEqual(float('%.4f' % smart_match.dissimilarity("aaa bbb", "aaa aaa")),  0.4286)
コード例 #7
0
    def test_dissimilarity(self):
        self.assertEqual(smart_match.dissimilarity('hello', 'hero'), 0.25)
        self.assertEqual(smart_match.dissimilarity('hello', 'ehllo'), 0)
        self.assertAlmostEqual(smart_match.dissimilarity('Healed', 'Sealed'),
                               0.16666666666666663)
        self.assertAlmostEqual(smart_match.dissimilarity('Healed', 'Healthy'),
                               0.33333333333333337)
        self.assertAlmostEqual(smart_match.dissimilarity('Healed', 'Heard'),
                               0.19999999999999996)
        self.assertAlmostEqual(smart_match.dissimilarity('Healed', 'Herded'),
                               0.33333333333333337)
        self.assertAlmostEqual(smart_match.dissimilarity('Healed', 'Help'),
                               0.25)
        self.assertAlmostEqual(smart_match.dissimilarity('Healed', 'Sold'),
                               0.5)

        smart_match.set_params(level='term')
        self.assertAlmostEqual(
            smart_match.dissimilarity('test string1', 'test string2'), 0.5)
        self.assertAlmostEqual(
            smart_match.dissimilarity('test', 'test string2'), 0)
        self.assertAlmostEqual(smart_match.dissimilarity('', 'test string2'),
                               1)
        self.assertAlmostEqual(
            smart_match.dissimilarity('aaa bbb ccc ddd', 'aaa bbb ccc eee'),
            0.25)
        self.assertAlmostEqual(
            smart_match.dissimilarity('aaa bbb ccc ddd aaa bbb ccc ddd',
                                      'aaa bbb ccc eee'), 0.25)

        smart_match.set_params(level='char')
        self.assertAlmostEqual(
            smart_match.similarity(("test", None), ("test", "string2")), 0.5)
コード例 #8
0
    def test_dissimilarity(self):
        self.assertAlmostEqual(smart_match.dissimilarity('hello', 'hero'), 0.3333333333333333)
        self.assertAlmostEqual(smart_match.dissimilarity('hello', 'ehllo'), 0)
        self.assertAlmostEqual(smart_match.dissimilarity("Healed", "Sealed"), 0.16666666666666666)
        self.assertAlmostEqual(smart_match.dissimilarity("Healed", "Healthy"), 0.38461538461538464)
        self.assertAlmostEqual(smart_match.dissimilarity("Healed", "Heard"), 0.2727272727272727)
        self.assertAlmostEqual(smart_match.dissimilarity("Healed", "Herded"), 0.3333333333333333)
        self.assertAlmostEqual(smart_match.dissimilarity("Healed", "Help"), 0.4)
        self.assertAlmostEqual(smart_match.dissimilarity("Healed", "Sold"), 0.6)
        self.assertAlmostEqual(smart_match.dissimilarity("Healed", "Help"), 0.4)

        smart_match.set_params(level='term')
        self.assertAlmostEqual(smart_match.dissimilarity('test string1', 'test string1'), 0.0000)
        self.assertAlmostEqual(smart_match.dissimilarity('test string1', 'test string2'), 0.5)
        self.assertAlmostEqual(smart_match.dissimilarity("test", "test string2"), 0.3333333333333333)
        self.assertAlmostEqual(smart_match.dissimilarity("", "test string2"), 1)
        self.assertAlmostEqual(smart_match.dissimilarity("aaa bbb ccc ddd", "aaa bbb ccc eee"), 0.25)
        self.assertAlmostEqual(smart_match.dissimilarity("aaa bbb", "aaa aaa"), 0.5)
        self.assertAlmostEqual(smart_match.dissimilarity("aaa", "aaa aaa"), 0.3333333333333333)
        self.assertAlmostEqual(smart_match.dissimilarity("a b c d", "a b c e"), 0.25)
        self.assertAlmostEqual(smart_match.dissimilarity("a b c d", "a b e f"), 0.5)
        self.assertAlmostEqual(smart_match.dissimilarity("a b c", "a b c e f g"), 0.3333333333333333)
        self.assertAlmostEqual(smart_match.dissimilarity("a b b c c", "a b c e f g"), 0.45454545454545453)

        smart_match.set_params(level='char')
        self.assertAlmostEqual(smart_match.dissimilarity(["test", ""], ["test", "string2"]), 0.5)
        self.assertAlmostEqual(smart_match.dissimilarity([], ["test", "string2"]), 1)
コード例 #9
0
 def test_dissimilarity(self):
     self.assertAlmostEqual(smart_match.dissimilarity('hello', 'hero'),
                            0.43305329048615915)
     smart_match.set_params(level='term')
     self.assertAlmostEqual(
         smart_match.dissimilarity('test string1', 'test string2'), 0.5)
コード例 #10
0
 def test_dissimilarity(self):
     self.assertAlmostEqual(
         smart_match.dissimilarity(['Hello', 'world'], ['Hero', 'world']),
         0.21652664524307963)
コード例 #11
0
    def test_dissimilarity(self):
        self.assertAlmostEqual(smart_match.dissimilarity('abbcccdd', 'aaabccee'), 0.5)
        self.assertAlmostEqual(smart_match.dissimilarity('hello', 'hollow'), 0.2727272727272727)

        smart_match.set_params(level='term')
        self.assertAlmostEqual(smart_match.dissimilarity('test string1', 'test string2'), 0.5)

        smart_match.set_params(level=2)
        self.assertAlmostEqual(smart_match.dissimilarity('test', 'test string2'), 0.5)
        self.assertAlmostEqual(smart_match.dissimilarity('test string1', 'test string2'), 0.11111111111111116)
        self.assertAlmostEqual(smart_match.dissimilarity('Healed', 'Sealed'), 0.19999999999999996)
        self.assertAlmostEqual(smart_match.dissimilarity('Healed', 'Healthy'), 0.4545454545454546)
        self.assertAlmostEqual(smart_match.dissimilarity('Healed', 'Heard'), 0.5555555555555556)
        self.assertAlmostEqual(smart_match.dissimilarity('Healed', 'Herded'), 0.6)
        self.assertAlmostEqual(smart_match.dissimilarity('Healed', 'Help'), 0.75)
        self.assertAlmostEqual(smart_match.dissimilarity('Healed', 'sold'), 1.0)
        self.assertAlmostEqual(smart_match.dissimilarity('Sam J Chapman', 'Samuel John Chapman'),0.2727272727272727)
        self.assertAlmostEqual(smart_match.dissimilarity('Sam Chapman', 'S Chapman'), 0.1428571428571429)
        self.assertAlmostEqual(smart_match.dissimilarity('John Smith', 'Samuel John Chapman'),0.7142857142857143)
        self.assertAlmostEqual(smart_match.dissimilarity('John Smith', 'Sam Chapman'), 1.0)
        self.assertAlmostEqual(smart_match.dissimilarity('John Smith', 'Sam J Chapman'), 1.0)
        self.assertAlmostEqual(smart_match.dissimilarity('John Smith', 'S Chapman'), 1.0)
        self.assertAlmostEqual(smart_match.dissimilarity('Web Database Applications', 'Web Database Applications with PHP & MySQL'),0.18367346938775508)
        self.assertAlmostEqual(smart_match.dissimilarity('Web Database Applications', 'Creating Database Web Applications with PHP and ASP'),0.2857142857142857)
        self.assertAlmostEqual(smart_match.dissimilarity('Web Database Applications', 'Building Database Applications on the Web Using PHP3'),0.29824561403508776)
        self.assertAlmostEqual(smart_match.dissimilarity('Web Database Applications','Building Web Database Applications with Visual Studio 6'),0.33333333333333337)
        self.assertAlmostEqual(smart_match.dissimilarity('Web Database Applications', 'Web Application Development With PHP'),0.4893617021276596)
        self.assertAlmostEqual(smart_match.dissimilarity('Web Database Applications','WebRAD: Building Database Applications on the Web with Visual FoxPro and Web Connection'),0.5121951219512195)
        self.assertAlmostEqual(smart_match.dissimilarity('Web Database Applications','Structural Assessment: The Role of Large and Full-Scale Testing'),0.9090909090909091)
        self.assertAlmostEqual(smart_match.dissimilarity('Web Database Applications', 'How to Find a Scholarship Online'),0.9512195121951219)
        self.assertAlmostEqual(smart_match.dissimilarity('Web Aplications', 'Web Database Applications with PHP & MySQL'),0.41463414634146345)
        self.assertAlmostEqual(smart_match.dissimilarity('Web Aplications', 'Creating Database Web Applications with PHP and ASP'), 0.5)
        self.assertAlmostEqual(smart_match.dissimilarity('Web Aplications', 'Building Database Applications on the Web Using PHP3'),0.5102040816326531)
        self.assertAlmostEqual(smart_match.dissimilarity('Web Aplications', 'Building Web Database Applications with Visual Studio 6'),0.5384615384615384)
        self.assertAlmostEqual(smart_match.dissimilarity('Web Aplications', 'Web Application Development With PHP'),0.4358974358974359)
        self.assertAlmostEqual(smart_match.dissimilarity('Web Aplications','WebRAD: Building Database Applications on the Web with Visual FoxPro and Web Connection'),0.6756756756756757)
        self.assertAlmostEqual(smart_match.dissimilarity('Web Aplications','Structural Assessment: The Role of Large and Full-Scale Testing'),0.9310344827586207)
        self.assertAlmostEqual(smart_match.dissimilarity('Web Aplications', 'How to Find a Scholarship Online'),0.9393939393939394)
コード例 #12
0
 def test_dissimilarity(self):
     self.assertEqual(smart_match.dissimilarity('hello', 'hill'), 0.4)
     self.assertEqual(
         smart_match.dissimilarity('test string1', 'test string2'),
         0.08333333333333337)
     self.assertEqual(smart_match.dissimilarity('test', 'test string2'),
                      0.6666666666666667)
     self.assertEqual(smart_match.dissimilarity('', 'test string2'), 1.0)
     self.assertEqual(
         smart_match.dissimilarity('aaa bbb ccc ddd', 'aaa bbb ccc eee'),
         0.19999999999999996)
     self.assertEqual(smart_match.dissimilarity('aaa bbb', 'aaa aaa'),
                      0.4285714285714286)
     self.assertEqual(smart_match.dissimilarity('aaa', 'aaa aaa'),
                      0.5714285714285714)
     self.assertEqual(smart_match.dissimilarity('a b c d', 'a b c e'),
                      0.1428571428571429)
     self.assertEqual(smart_match.dissimilarity('transpose', 'tranpsose'),
                      0.11111111111111116)
     self.assertEqual(smart_match.dissimilarity('uxyw', 'uyxw'), 0.25)
     self.assertEqual(smart_match.dissimilarity('uxaayw', 'uyxw'), 0.5)
     self.assertEqual(smart_match.dissimilarity('Healed', 'Sealed'),
                      0.16666666666666663)
     self.assertEqual(smart_match.dissimilarity('Healed', 'Healthy'),
                      0.4285714285714286)
     self.assertEqual(smart_match.dissimilarity('Healed', 'Heard'),
                      0.33333333333333337)
     self.assertEqual(smart_match.dissimilarity('Healed', 'Herded'),
                      0.33333333333333337)
     self.assertEqual(smart_match.dissimilarity('Healed', 'Help'), 0.5)
     self.assertEqual(smart_match.dissimilarity('Healed', 'sold'),
                      0.6666666666666667)
     self.assertEqual(
         smart_match.dissimilarity('Sam J Chapman', 'Samuel John Chapman'),
         0.3157894736842105)
     self.assertEqual(smart_match.dissimilarity('Sam Chapman', 'S Chapman'),
                      0.18181818181818177)
     self.assertEqual(
         smart_match.dissimilarity('John Smith', 'Samuel John Chapman'),
         0.6842105263157895)
     self.assertEqual(
         smart_match.dissimilarity('John Smith', 'Sam Chapman'),
         0.7272727272727273)
     self.assertEqual(
         smart_match.dissimilarity('John Smith', 'Sam J Chapman'),
         0.7692307692307692)
     self.assertEqual(smart_match.dissimilarity('John Smith', 'S Chapman'),
                      0.8)
     self.assertEqual(
         smart_match.dissimilarity(
             'Web Database Applications',
             'Web Database Applications with PHP & MySQL'),
         0.40476190476190477)
     self.assertEqual(
         smart_match.dissimilarity(
             'Web Database Applications',
             'Creating Database Web Applications with PHP and ASP'),
         0.5490196078431373)
     self.assertEqual(
         smart_match.dissimilarity(
             'Web Database Applications',
             'Building Database Applications on the Web Using PHP3'),
         0.5769230769230769)
     self.assertEqual(
         smart_match.dissimilarity(
             'Web Database Applications',
             'Building Web Database Applications with Visual Studio 6'),
         0.5454545454545454)
     self.assertEqual(
         smart_match.dissimilarity('Web Database Applications',
                                   'Web Application Development With PHP'),
         0.5833333333333333)
     self.assertEqual(
         smart_match.dissimilarity(
             'Web Database Applications',
             'WebRAD: Building Database Applications on the Web with Visual FoxPro and Web Connection'
         ), 0.7126436781609196)
     self.assertEqual(
         smart_match.dissimilarity(
             'Web Database Applications',
             'Structural Assessment: The Role of Large and Full-Scale Testing'
         ), 0.8253968253968254)
     self.assertEqual(
         smart_match.dissimilarity('Web Database Applications',
                                   'How to Find a Scholarship Online'),
         0.71875)
     self.assertEqual(
         smart_match.dissimilarity(
             'Web Aplications',
             'Web Database Applications with PHP & MySQL'),
         0.6428571428571428)
     self.assertEqual(
         smart_match.dissimilarity(
             'Web Aplications',
             'Creating Database Web Applications with PHP and ASP'),
         0.7058823529411764)
     self.assertEqual(
         smart_match.dissimilarity(
             'Web Aplications',
             'Building Database Applications on the Web Using PHP3'), 0.75)
     self.assertEqual(
         smart_match.dissimilarity(
             'Web Aplications',
             'Building Web Database Applications with Visual Studio 6'),
         0.7272727272727273)
     self.assertEqual(
         smart_match.dissimilarity('Web Aplications',
                                   'Web Application Development With PHP'),
         0.6111111111111112)
     self.assertEqual(
         smart_match.dissimilarity(
             'Web Aplications',
             'WebRAD: Building Database Applications on the Web with Visual FoxPro and Web Connection'
         ), 0.8275862068965517)
     self.assertEqual(
         smart_match.dissimilarity(
             'Web Aplications',
             'Structural Assessment: The Role of Large and Full-Scale Testing'
         ), 0.873015873015873)
     self.assertEqual(
         smart_match.dissimilarity('Web Aplications',
                                   'How to Find a Scholarship Online'),
         0.8125)
コード例 #13
0
 def test_dissimilarity(self):
     self.assertEqual(smart_match.dissimilarity('hello', 'low'), 0.6)
     self.assertEqual(
         smart_match.dissimilarity('test string1', 'test string2'),
         0.08333333333333337)
     self.assertEqual(smart_match.dissimilarity('test', 'test string2'),
                      0.6666666666666667)
     self.assertEqual(smart_match.dissimilarity('', 'test string2'), 1.0)
     self.assertEqual(
         smart_match.dissimilarity('aaa bbb ccc ddd', 'aaa bbb ccc eee'),
         0.19999999999999996)
     self.assertEqual(smart_match.dissimilarity('aaa bbb', 'aaa aaa'),
                      0.4285714285714286)
     self.assertEqual(smart_match.dissimilarity('aaa', 'aaa aaa'),
                      0.5714285714285714)
     self.assertEqual(smart_match.dissimilarity('a b c d', 'a b c e'),
                      0.1428571428571429)
     self.assertEqual(smart_match.dissimilarity('uxyw', 'uyxw'), 0.75)
     self.assertEqual(smart_match.dissimilarity('uxaayw', 'uyxw'),
                      0.8333333333333334)
     self.assertEqual(smart_match.dissimilarity('transpose', 'tranpsose'),
                      0.5555555555555556)
     self.assertEqual(smart_match.dissimilarity('Healed', 'Sealed'),
                      0.16666666666666663)
     self.assertEqual(smart_match.dissimilarity('Healed', 'Healthy'),
                      0.4285714285714286)
     self.assertEqual(smart_match.dissimilarity('Healed', 'Heard'), 0.5)
     self.assertEqual(smart_match.dissimilarity('Healed', 'Help'),
                      0.6666666666666667)
     self.assertEqual(smart_match.dissimilarity('Healed', 'Sold'),
                      0.8333333333333334)
     self.assertEqual(
         smart_match.dissimilarity('Sam J Chapman', 'Samuel John Chapman'),
         0.5789473684210527)
     self.assertEqual(smart_match.dissimilarity('Sam Chapman', 'S Chapman'),
                      0.2727272727272727)
     self.assertEqual(
         smart_match.dissimilarity('John Smith', 'Samuel John Chapman'),
         0.736842105263158)
     self.assertEqual(
         smart_match.dissimilarity('John Smith', 'Sam Chapman'),
         0.9090909090909091)
     self.assertEqual(
         smart_match.dissimilarity('John Smith', 'Sam J Chapman'),
         0.9230769230769231)
     self.assertEqual(smart_match.dissimilarity('John Smith', 'S Chapman'),
                      0.9)
     self.assertEqual(
         smart_match.dissimilarity(
             'Web Database Applications',
             'Web Database Applications with PHP & MySQL'),
         0.40476190476190477)
     self.assertEqual(
         smart_match.dissimilarity(
             'Web Database Applications',
             'Creating Database Web Applications with PHP and ASP'),
         0.7450980392156863)
     self.assertEqual(
         smart_match.dissimilarity(
             'Web Database Applications',
             'Building Database Applications on the Web Using PHP3'),
         0.5769230769230769)
     self.assertEqual(
         smart_match.dissimilarity(
             'Web Database Applications',
             'Building Web Database Applications with Visual Studio 6'),
         0.5454545454545454)
     self.assertEqual(
         smart_match.dissimilarity('Web Database Applications',
                                   'Web Application Development With PHP'),
         0.6666666666666667)
     self.assertEqual(
         smart_match.dissimilarity(
             'Web Database Applications',
             'WebRAD: Building Database Applications on the Web with Visual FoxPro and Web Connection'
         ), 0.7471264367816092)
     self.assertEqual(
         smart_match.dissimilarity(
             'Web Database Applications',
             'Structural Assessment: The Role of Large and Full-Scale Testing'
         ), 0.9682539682539683)
     self.assertEqual(
         smart_match.dissimilarity('Web Database Applications',
                                   'How to Find a Scholarship Online'),
         0.9375)
     self.assertEqual(
         smart_match.dissimilarity(
             'Web Aplications',
             'Web Database Applications with PHP & MySQL'),
         0.7619047619047619)
     self.assertEqual(
         smart_match.dissimilarity(
             'Web Aplications',
             'Creating Database Web Applications with PHP and ASP'),
         0.803921568627451)
     self.assertEqual(
         smart_match.dissimilarity(
             'Web Aplications',
             'Building Database Applications on the Web Using PHP3'),
         0.8076923076923077)
     self.assertEqual(
         smart_match.dissimilarity(
             'Web Aplications',
             'Building Web Database Applications with Visual Studio 6'),
         0.8181818181818181)
     self.assertEqual(
         smart_match.dissimilarity('Web Aplications',
                                   'Web Application Development With PHP'),
         0.75)
     self.assertEqual(
         smart_match.dissimilarity(
             'Web Aplications',
             'Structural Assessment: The Role of Large and Full-Scale Testing'
         ), 0.9682539682539683)
     self.assertEqual(
         smart_match.dissimilarity('Web Aplications',
                                   'How to Find a Scholarship Online'),
         0.9375)
コード例 #14
0
 def test_dissimilarity(self):
     self.assertAlmostEqual(
         smart_match.dissimilarity('Web Aplications',
                                   'Web Application Development With PHP'),
         0.1333333333333333)
コード例 #15
0
 def test_dissimilarity(self):
     self.assertAlmostEqual(smart_match.dissimilarity('abbcccdd', 'aaabccee'), 0.5)
     self.assertAlmostEqual(smart_match.dissimilarity('hello', 'hollow'), 0.2727272727272727)
     smart_match.set_params(level='term')
     self.assertAlmostEqual(smart_match.dissimilarity('test string1', 'test string2'), 0.5)
コード例 #16
0
 def test_dissimilarity(self):
     self.assertAlmostEqual(smart_match.dissimilarity('hello', 'hero'),
                            0.34921514788478913)
コード例 #17
0
    def test_dissimilarity(self):
        self.assertAlmostEqual(smart_match.dissimilarity('hello', 'hero'), 0.43305329048615915)
        smart_match.set_params(level='term')
        self.assertAlmostEqual(smart_match.dissimilarity('test string1', 'test string2'), 0.5)
        self.assertAlmostEqual(smart_match.dissimilarity('test', 'test string2'), 0.29289321881345254)
        self.assertAlmostEqual(smart_match.dissimilarity('', 'test string2'), 1.0)
        self.assertAlmostEqual(smart_match.dissimilarity('aaa bbb ccc ddd', 'aaa bbb ccc eee'), 0.25)
        self.assertAlmostEqual(smart_match.dissimilarity('a b c d', 'a b c e'), 0.25)
        self.assertAlmostEqual(smart_match.dissimilarity('a b c d', 'a b e f'), 0.5)
        self.assertAlmostEqual(smart_match.dissimilarity('a b c', 'a b c e f g'), 0.2928932188134524)
        self.assertAlmostEqual(smart_match.dissimilarity('Healed', 'Sealed'), 1.0)
        self.assertAlmostEqual(smart_match.dissimilarity('Healed', 'Healthy'), 1.0)
        self.assertAlmostEqual(smart_match.dissimilarity('Healed', 'Heard'), 1.0)
        self.assertAlmostEqual(smart_match.dissimilarity('Healed', 'Help'), 1.0)
        self.assertAlmostEqual(smart_match.dissimilarity('Healed', 'Sold'), 1.0)
        self.assertAlmostEqual(smart_match.dissimilarity('Healed', 'Help'), 1.0)
        self.assertAlmostEqual(smart_match.dissimilarity('Sam J Chapman', 'Samuel John Chapman'),  0.6666666666666666)
        self.assertAlmostEqual(smart_match.dissimilarity('Sam Chapman', 'S Chapman'),  0.5000000000000001)
        self.assertAlmostEqual(smart_match.dissimilarity('John Smith', 'Samuel John Chapman'), 0.5917517095361371)
        self.assertAlmostEqual(smart_match.dissimilarity('John Smith', 'Sam Chapman'), 1.0)
        self.assertAlmostEqual(smart_match.dissimilarity('John Smith', 'Sam J Chapman'), 1.0)
        self.assertAlmostEqual(smart_match.dissimilarity('John Smith', 'S Chapman'), 1.0)
        self.assertAlmostEqual(smart_match.dissimilarity('Web Database Applications',
                                                         'Web Database Applications with PHP & MySQL'),
                               0.3453463292920228)
        self.assertAlmostEqual(smart_match.dissimilarity('Web Database Applications',
                                                         'Creating Database Web Applications with PHP and ASP'),
                               0.38762756430420553)
        self.assertAlmostEqual(smart_match.dissimilarity('Web Database Applications',
                                                         'Building Database Applications on the Web Using PHP3'),
                               0.38762756430420553)
        self.assertAlmostEqual(smart_match.dissimilarity('Web Database Applications',
                                                         'Building Web Database Applications with Visual Studio 6'),
                               0.38762756430420553)
        self.assertAlmostEqual(smart_match.dissimilarity('Web Database Applications',
                                                         'Web Application Development With PHP'),
                               0.7418011102528389)

        self.assertAlmostEqual(smart_match.dissimilarity('Web Database Applications',
                                                         'WebRAD: Building Database Applications on the'
                                                         ' Web with Visual FoxPro and Web Connection'),
                               0.40371520600005606)
        self.assertAlmostEqual(smart_match.dissimilarity('Web Database Applications',
                                                         'Structural Assessment: The Role of Large and'
                                                         ' Full-Scale Testing'), 1.0)
        self.assertAlmostEqual(smart_match.dissimilarity('Web Database Applications',
                                                         'How to Find a Scholarship Online'), 1.0)
        self.assertAlmostEqual(smart_match.dissimilarity('Web Aplications',
                                                         'Web Database Applications with PHP & MySQL'), 0.7327387580875757)
コード例 #18
0
 def test_dissimilarity(self):
     self.assertAlmostEqual(smart_match.dissimilarity('hello', 'helo'), 0.2)
コード例 #19
0
    def test_dissimilarity(self):
        self.assertAlmostEqual(
            float('%.4f' %
                  smart_match.dissimilarity("test string1", "test string2")),
            0.0833)
        self.assertAlmostEqual(
            float('%.4f' % smart_match.dissimilarity("test", "test string2")),
            0.0000)
        self.assertAlmostEqual(
            float('%.4f' % smart_match.dissimilarity("", "test string2")),
            1.0000)
        self.assertAlmostEqual(
            float('%.4f' % smart_match.dissimilarity(
                "aaa bbb ccc ddd", "aaa bbb ccc eee")), 0.2000)
        self.assertAlmostEqual(
            float('%.4f' % smart_match.dissimilarity("a b c d", "a b c e")),
            0.1429)
        self.assertAlmostEqual(
            float('%.4f' % smart_match.dissimilarity("Healed", "Sealed")),
            0.1667)
        self.assertAlmostEqual(
            float('%.4f' % smart_match.dissimilarity("Healed", "Healthy")),
            0.3333)
        self.assertAlmostEqual(
            float('%.4f' % smart_match.dissimilarity("Healed", "Heard")),
            0.4000)
        self.assertAlmostEqual(
            float('%.4f' % smart_match.dissimilarity("Healed", "Herded")),
            0.6667)

        self.assertAlmostEqual(
            float('%.4f' % smart_match.dissimilarity(
                "Sam J Chapman", "Samuel John Chapman")), 0.2308)
        self.assertAlmostEqual(
            float('%.4f' %
                  smart_match.dissimilarity("Sam Chapman", "S Chapman")),
            0.1111)
        self.assertAlmostEqual(
            float('%.4f' % smart_match.dissimilarity(
                "John Smith", "Samuel John Chapman")), 0.5000)
        self.assertAlmostEqual(
            float('%.4f' % smart_match.dissimilarity(
                "aaa bbb ccc ddd", "aaa bbb ccc eee")), 0.2000)
        self.assertAlmostEqual(
            float('%.4f' %
                  smart_match.dissimilarity("John Smith", "Sam Chapman")),
            0.8500)
        self.assertAlmostEqual(
            float('%.4f' %
                  smart_match.dissimilarity("John Smith", "S Chapman")),
            0.8889)
        self.assertAlmostEqual(
            float('%.4f' % smart_match.dissimilarity(
                "Web Database Applications",
                "Web Database Applications with PHP & MySQL")), 0.0000)
        self.assertAlmostEqual(
            float('%.4f' % smart_match.dissimilarity(
                "Web Database Applications",
                "Building Web Database Applications with Visual Studio 6")),
            0.0000)
        self.assertAlmostEqual(
            float('%.4f' % smart_match.dissimilarity(
                "Web Database Applications",
                "Web Application Development With PHP")), 0.5000)

        self.assertAlmostEqual(
            float('%.4f' % smart_match.dissimilarity(
                "Web Database Applications",
                "WebRAD: Building Database Applications on the Web with Visual FoxPro and Web Connection"
            )), 0.1200)
        self.assertAlmostEqual(
            float('%.4f' % smart_match.dissimilarity(
                "Web Database Applications",
                "Structural Assessment: The Role of Large and Full-Scale Testing"
            )), 0.9000)
        self.assertAlmostEqual(
            float(
                '%.4f' %
                smart_match.dissimilarity("Web Database Applications",
                                          "How to Find a Scholarship Online")),
            0.9200)
        self.assertAlmostEqual(
            float('%.4f' % smart_match.dissimilarity(
                "Web Aplications",
                "Web Database Applications with PHP & MySQL")), 0.2000)
        self.assertAlmostEqual(
            float('%.4f' % smart_match.dissimilarity(
                "Web Aplications",
                "Creating Database Web Applications with PHP and ASP")),
            0.0333)
        self.assertAlmostEqual(
            float('%.4f' % smart_match.dissimilarity(
                "Web Aplications", "Web Application Development With PHP")),
            0.1000)
        self.assertAlmostEqual(
            float('%.4f' % smart_match.dissimilarity(
                "Web Aplications",
                "Structural Assessment: The Role of Large and Full-Scale Testing"
            )), 0.8333)
        self.assertAlmostEqual(
            float('%.4f' % smart_match.dissimilarity(
                "Web Aplications", "How to Find a Scholarship Online")),
            0.8667)
        self.assertAlmostEqual(
            float('%.4f' % smart_match.dissimilarity('GGTTGACTA', 'TGTTACGG')),
            0.4375)
        smart_match.set_params(gap=-2, match=3, mismatch=-3)
        self.assertAlmostEqual(
            float('%.4f' % smart_match.dissimilarity('GGTTGACTA', 'TGTTACGG')),
            0.4583)
コード例 #20
0
 def test_dissimilarity(self):
     self.assertEqual(smart_match.dissimilarity('hello', 'hero'), 0.4)
     self.assertEqual(smart_match.dissimilarity('Subsitute', 'Subsytute'),
                      0.1111111111111111)
     self.assertEqual(smart_match.dissimilarity('Subsitute', 'Sybsytyte'),
                      0.3333333333333333)
     self.assertEqual(smart_match.dissimilarity('abc', 'abcdef'), 0.5)
     self.assertEqual(smart_match.dissimilarity('def', 'abcdef'), 0.5)
     self.assertEqual(
         smart_match.dissimilarity('test string1', 'test string2'),
         0.08333333333333333)
     self.assertEqual(smart_match.dissimilarity('test', 'test string2'),
                      0.6666666666666666)
     self.assertEqual(smart_match.dissimilarity('', 'test string2'), 1.0)
     self.assertEqual(
         smart_match.dissimilarity('aaa bbb ccc ddd', 'aaa bbb ccc eee'),
         0.2)
     self.assertEqual(smart_match.dissimilarity('aaa bbb', 'aaa aaa'),
                      0.42857142857142855)
     self.assertEqual(smart_match.dissimilarity('aaa', 'aaa aaa'),
                      0.5714285714285714)
     self.assertEqual(smart_match.dissimilarity('a b c d', 'a b c e'),
                      0.14285714285714285)
     self.assertEqual(smart_match.dissimilarity('Healed', 'Sealed'),
                      0.16666666666666666)
     self.assertEqual(smart_match.dissimilarity('Healed', 'Healthy'),
                      0.42857142857142855)
     self.assertEqual(smart_match.dissimilarity('Healed', 'Heard'),
                      0.33333333333333333)
     self.assertEqual(smart_match.dissimilarity('Healed', 'Herded'),
                      0.33333333333333333)
     self.assertEqual(smart_match.dissimilarity('Healed', 'Help'), 0.5)
     self.assertEqual(smart_match.dissimilarity('Healed', 'Sold'),
                      0.6666666666666666)
     self.assertEqual(smart_match.dissimilarity('Healed', 'Help'), 0.5)
     self.assertEqual(
         smart_match.dissimilarity('Sam J Chapman', 'Samuel John Chapman'),
         0.3157894736842105)
     self.assertEqual(smart_match.dissimilarity('Sam Chapman', 'S Chapman'),
                      0.18181818181818182)
     self.assertEqual(
         smart_match.dissimilarity('John Smith', 'Samuel John Chapman'),
         0.7368421052631579)
     self.assertEqual(
         smart_match.dissimilarity('John Smith', 'Sam Chapman'), 1.0)
     self.assertEqual(
         smart_match.dissimilarity('John Smith', 'Sam J Chapman'),
         0.9230769230769231)
     self.assertEqual(smart_match.dissimilarity('John Smith', 'S Chapman'),
                      0.9)
     self.assertEqual(
         smart_match.dissimilarity(
             'Web Database Applications',
             'Web Database Applications with PHP & MySQL'),
         0.40476190476190477)
     self.assertEqual(
         smart_match.dissimilarity(
             'Web Database Applications',
             'Creating Database Web Applications with PHP and ASP'),
         0.5490196078431373)
     self.assertEqual(
         smart_match.dissimilarity(
             'Web Database Applications',
             'Building Database Applications on the Web Using PHP3'),
         0.5769230769230769)
     self.assertEqual(
         smart_match.dissimilarity(
             'Web Database Applications',
             'Building Web Database Applications with Visual Studio 6'),
         0.5454545454545454)
     self.assertEqual(
         smart_match.dissimilarity('Web Database Applications',
                                   'Web Application Development With PHP'),
         0.75)
     self.assertEqual(
         smart_match.dissimilarity(
             'Web Database Applications',
             'WebRAD: Building Database Applications on the Web with Visual FoxPro and Web Connection'
         ), 0.7126436781609196)
     self.assertEqual(
         smart_match.dissimilarity(
             'Web Database Applications',
             'Structural Assessment: The Role of Large and Full-Scale Testing'
         ), 0.8412698412698413)
     self.assertEqual(
         smart_match.dissimilarity('Web Database Applications',
                                   'How to Find a Scholarship Online'),
         0.84375)
     self.assertEqual(
         smart_match.dissimilarity(
             'Web Aplications',
             'Web Database Applications with PHP & MySQL'),
         0.6428571428571429)
     self.assertEqual(
         smart_match.dissimilarity(
             'Web Aplications',
             'Creating Database Web Applications with PHP and ASP'),
         0.7058823529411765)
     self.assertEqual(
         smart_match.dissimilarity(
             'Web Aplications',
             'Building Database Applications on the Web Using PHP3'), 0.75)
     self.assertEqual(
         smart_match.dissimilarity(
             'Web Aplications',
             'Building Web Database Applications with Visual Studio 6'),
         0.7272727272727273)
     self.assertEqual(
         smart_match.dissimilarity('Web Aplications',
                                   'Web Application Development With PHP'),
         0.6111111111111112)
     self.assertEqual(
         smart_match.dissimilarity(
             'Web Aplications',
             'WebRAD: Building Database Applications on the Web with Visual FoxPro and Web Connection'
         ), 0.8275862068965517)
     self.assertEqual(
         smart_match.dissimilarity(
             'Web Aplications',
             'Structural Assessment: The Role of Large and Full-Scale Testing'
         ), 0.8888888888888888)
     self.assertEqual(
         smart_match.dissimilarity('Web Aplications',
                                   'How to Find a Scholarship Online'),
         0.8125)
コード例 #21
0
 def test_dissimilarity(self):
     self.assertAlmostEqual(smart_match.dissimilarity('hello', 'hero'), 0.34921514788478913)
     self.assertAlmostEqual(smart_match.dissimilarity('hello', 'ehllo'),0.0)
     self.assertAlmostEqual(smart_match.dissimilarity('test string1', 'test string2'), 0.08333333333333334)
     self.assertAlmostEqual(smart_match.dissimilarity('test','test string2'),0.22360679774997896)
     self.assertAlmostEqual(smart_match.dissimilarity('','test string2'),0.37267799624996495)
     self.assertAlmostEqual(smart_match.dissimilarity('aaa bbb ccc ddd','aaa bbb ccc eee'),0.19999999999999998)
     self.assertAlmostEqual(smart_match.dissimilarity('a b c d','a b c e'),0.14285714285714288)
     self.assertAlmostEqual(smart_match.dissimilarity('a b c d','a b c e f'),0.17541160386140586)
     self.assertAlmostEqual(smart_match.dissimilarity('a b c d','a b e f'),0.20203050891044214)
     self.assertAlmostEqual(smart_match.dissimilarity('a b c','a b c e f g'),0.28669108954049793)
     self.assertAlmostEqual(smart_match.dissimilarity('a b b c c','a b c e f g'),0.1723454968864278)
     self.assertAlmostEqual(smart_match.dissimilarity('Healed','Sealed'),0.16666666666666669)
     self.assertAlmostEqual(smart_match.dissimilarity('Healed','Healthy'),0.242535625036333)
     self.assertAlmostEqual(smart_match.dissimilarity('Healed','Heard'),0.22176638128637186)
     self.assertAlmostEqual(smart_match.dissimilarity('Healed','Herded'),0.23570226039551587)
     self.assertAlmostEqual(smart_match.dissimilarity('Healed','Help'),0.2773500981126146)
     self.assertAlmostEqual(smart_match.dissimilarity('Healed','Sold'),0.3922322702763681)
     self.assertAlmostEqual(smart_match.dissimilarity('Healed','Help'),0.2773500981126146)
     self.assertAlmostEqual(smart_match.dissimilarity('Healed','So'),0.5)
     self.assertAlmostEqual(smart_match.dissimilarity('Sam J Chapman','Samuel John Chapman'),0.1063990353197863)
     self.assertAlmostEqual(smart_match.dissimilarity('Sam Chapman','S Chapman'),0.09950371902099893)
     self.assertAlmostEqual(smart_match.dissimilarity('John Smith','Samuel John Chapman'),0.2030141634031955)
     self.assertAlmostEqual(smart_match.dissimilarity('John Smith','Sam Chapman'),0.2773500981126146)
     self.assertAlmostEqual(smart_match.dissimilarity('John Smith','Sam J Chapman'),0.25139018680589903)
     self.assertAlmostEqual(smart_match.dissimilarity('John Smith','S Chapman'),0.2465227791969404)
     self.assertAlmostEqual(smart_match.dissimilarity('Web Database Applications','Web Database Applications with PHP & MySQL'),0.11391286426309005)
     self.assertAlmostEqual(smart_match.dissimilarity('Web Database Applications','Creating Database Web Applications with PHP and ASP'),0.13637772569945572)
     self.assertAlmostEqual(smart_match.dissimilarity('Web Database Applications','Building Database Applications on the Web Using PHP3'),0.13756671829544148)
     self.assertAlmostEqual(smart_match.dissimilarity('Web Database Applications','Building Web Database Applications with Visual Studio 6'),0.14988580127769788)
     self.assertAlmostEqual(smart_match.dissimilarity('Web Database Applications','Web Application Development With PHP'),0.13878329029749603)
     self.assertAlmostEqual(smart_match.dissimilarity('Web Database Applications','WebRAD: Building Database Applications on the Web with Visual FoxPro and Web Connection'),0.1760633165448035)
     self.assertAlmostEqual(smart_match.dissimilarity('Web Database Applications','Structural Assessment: The Role of Large and Full-Scale Testing'),0.17827109516018724)
     self.assertAlmostEqual(smart_match.dissimilarity('Web Database Applications','How to Find a Scholarship Online'),0.16519463133513965)
     self.assertAlmostEqual(smart_match.dissimilarity('Web Aplications','Web Database Applications with PHP & MySQL'),0.16928560745943824)
     self.assertAlmostEqual(smart_match.dissimilarity('Web Aplications','Creating Database Web Applications with PHP and ASP'),0.19183621228155442)
     self.assertAlmostEqual(smart_match.dissimilarity('Web Aplications','Building Database Applications on the Web Using PHP3'),0.18009519124771117)
     self.assertAlmostEqual(smart_match.dissimilarity('Web Aplications','Web Application Development With PHP'),0.16418267275468842)
     self.assertAlmostEqual(smart_match.dissimilarity('Web Aplications','WebRAD: Building Database Applications on the Web with Visual FoxPro and Web Connection'),0.20388829980917544)
     self.assertAlmostEqual(smart_match.dissimilarity('Web Aplications','Structural Assessment: The Role of Large and Full-Scale Testing'),0.20945691294067176)
     self.assertAlmostEqual(smart_match.dissimilarity('Web Aplications','How to Find a Scholarship Online'),0.18118018933869962)
コード例 #22
0
 def test_dissimilarity(self):
     self.assertAlmostEqual(smart_match.dissimilarity('hello', 'helo'), 0)
     smart_match.set_params(level='term')
     self.assertAlmostEqual(
         smart_match.dissimilarity('test string1', 'test string2'),
         0.6666666666666667)
コード例 #23
0
    def test_dissimilarity(self):
        self.assertAlmostEqual(smart_match.dissimilarity('hello', 'helo'), 0.2)
        self.assertAlmostEqual(smart_match.dissimilarity('abcd', 'abce'), 0.4)
        self.assertAlmostEqual(smart_match.dissimilarity('abcd', 'abef'),
                               0.6666666666666667)
        self.assertAlmostEqual(smart_match.dissimilarity('abc', 'abcefg'), 0.5)
        self.assertAlmostEqual(smart_match.dissimilarity('abbcc', 'abcefg'),
                               0.625)

        smart_match.set_params(level='term')
        self.assertAlmostEqual(
            smart_match.dissimilarity('test string1', 'test string2'),
            0.6666666666666667)
        self.assertAlmostEqual(
            smart_match.dissimilarity('test', 'test string2'), 0.5)
        self.assertAlmostEqual(smart_match.dissimilarity('', 'test string2'),
                               1)
        self.assertAlmostEqual(
            smart_match.dissimilarity('aaa bbb ccc ddd', 'aaa bbb ccc eee'),
            0.4)
        self.assertAlmostEqual(
            smart_match.dissimilarity('aaa bbb ccc ddd aaa bbb ccc ddd',
                                      'aaa bbb ccc eee'), 0.6666666666666667)

        smart_match.set_params(level='char')
        self.assertAlmostEqual(
            smart_match.dissimilarity(('test', None), ('test', 'string2')),
            0.6666666666666667)
コード例 #24
0
 def test_dissimilarity(self):
     self.assertEqual(
         smart_match.dissimilarity(['Hello', 'world'], ['Hero', 'world']),
         0.2)
コード例 #25
0
    def test_dissimilarity(self):
        self.assertAlmostEqual(float('%.4f' % smart_match.dissimilarity('test', 'test string1')), 0.4226)
        smart_match.set_params(level='term')
        self.assertAlmostEqual(float('%.4f' % smart_match.dissimilarity("test string1", "test string2")), 0.5000)
        self.assertAlmostEqual(float('%.4f' % smart_match.dissimilarity("test", "test string2")), 0.2929)
        self.assertAlmostEqual(float('%.4f' % smart_match.dissimilarity("", "test string2")), 1.0000)

        self.assertAlmostEqual(float('%.4f' % smart_match.dissimilarity("aaa bbb ccc ddd", "aaa bbb ccc eee")), 0.2500)
        self.assertAlmostEqual(
            float('%.4f' % smart_match.dissimilarity("aaa bbb ccc ddd aaa bbb ccc ddd", "aaa bbb ccc eee")), 0.2500)

        self.assertAlmostEqual(float('%.4f' % smart_match.dissimilarity("a b c d", "a b c e")), 0.2500)
        self.assertAlmostEqual(float('%.4f' % smart_match.dissimilarity("a b c d", "a b e f")), 0.5000)
        self.assertAlmostEqual(float('%.4f' % smart_match.dissimilarity("a b c", "a b c e f g")), 0.2929)
        self.assertAlmostEqual(float('%.4f' % smart_match.dissimilarity("a b b c c", "a b c e f g")), 0.2929)

        self.assertAlmostEqual(float('%.4f' % smart_match.dissimilarity("Healed", "Sealed")), 1.0000)
        self.assertAlmostEqual(float('%.4f' % smart_match.dissimilarity("Healed", "Healthy")), 1.0000)
        self.assertAlmostEqual(float('%.4f' % smart_match.dissimilarity("Healed", "Heard")), 1.0000)
        self.assertAlmostEqual(float('%.4f' % smart_match.dissimilarity("Healed", "Herded")), 1.0000)
        self.assertAlmostEqual(float('%.4f' % smart_match.dissimilarity("Healed", "Help")), 1.0000)
        self.assertAlmostEqual(float('%.4f' % smart_match.dissimilarity("Healed", "Sold")), 1.0000)
        self.assertAlmostEqual(float('%.4f' % smart_match.dissimilarity("Healed", "Help")), 1.0000)

        self.assertAlmostEqual(float('%.4f' % smart_match.dissimilarity("Sam J Chapman", "Samuel John Chapman")),
                               0.6667)
        self.assertAlmostEqual(float('%.4f' % smart_match.dissimilarity("Sam Chapman", "S Chapman")), 0.5000)
        self.assertAlmostEqual(float('%.4f' % smart_match.dissimilarity("John Smith", "Samuel John Chapman")), 0.5918)
        self.assertAlmostEqual(float('%.4f' % smart_match.dissimilarity("John Smith", "Sam Chapman")), 1.0000)
        self.assertAlmostEqual(float('%.4f' % smart_match.dissimilarity("John Smith", "Sam J Chapman")), 1.0000)
        self.assertAlmostEqual(float('%.4f' % smart_match.dissimilarity("John Smith", "S Chapman")), 1.0000)

        self.assertAlmostEqual(float('%.4f' % smart_match.dissimilarity("Web Database Applications",
                                                                     "Web Database Applications with PHP & MySQL")),
                               0.3453)
        self.assertAlmostEqual(float('%.4f' % smart_match.dissimilarity("Web Database Applications",
                                                                     "Creating Database Web Applications with PHP and ASP")),
                               0.3876)
        self.assertAlmostEqual(float('%.4f' % smart_match.dissimilarity("Web Database Applications",
                                                                     "Structural Assessment: The Role of Large and Full-Scale Testing")),
                               1.0000)
        self.assertAlmostEqual(float(
            '%.4f' % smart_match.dissimilarity("Web Database Applications", "Web Application Development With PHP")),
                               0.7418)
        self.assertAlmostEqual(
            float('%.4f' % smart_match.dissimilarity("Web Aplications", "Web Application Development With PHP")),
            0.6838)
        self.assertAlmostEqual(
            float('%.4f' % smart_match.dissimilarity("Web Aplications", "Web Database Applications with PHP & MySQL")),
            0.7327)
コード例 #26
0
 def test_dissimilarity(self):
     self.assertEqual(smart_match.dissimilarity('hello', 'hero'), 0.25)
     self.assertEqual(smart_match.dissimilarity('hello', 'ehllo'), 0)
     smart_match.set_params(level='term')
     self.assertAlmostEqual(
         smart_match.dissimilarity('test string1', 'test string2'), 0.5)
     self.assertEqual(smart_match.dissimilarity("Sam Chapman", "S Chapman"),
                      0.5000)
     self.assertEqual(
         smart_match.dissimilarity("John Smith", "Samuel John Chapman"),
         0.5000)
     self.assertEqual(
         smart_match.dissimilarity("John Smith", "Sam Chapman"), 1.0000)
     self.assertEqual(
         smart_match.dissimilarity("John Smith", "Sam J Chapman"), 1.0000)
     self.assertEqual(smart_match.dissimilarity("John Smith", "S Chapman"),
                      1.0000)
     self.assertEqual(smart_match.dissimilarity("a b b c c", "a b c e f g"),
                      0.0000)
     self.assertEqual(smart_match.dissimilarity("Healed", "Sealed"), 1.0000)
     self.assertEqual(smart_match.dissimilarity("Healed", "Healthy"),
                      1.0000)
     self.assertEqual(smart_match.dissimilarity("Healed", "Heard"), 1.0000)
     self.assertEqual(
         smart_match.dissimilarity(
             "Web Database Applications",
             "Web Database Applications with PHP & MySQL"), 0.0000)
     self.assertEqual(
         smart_match.dissimilarity(
             "Web Database Applications",
             "Creating Database Web Applications with PHP and ASP"), 0.0000)
     self.assertEqual(
         smart_match.dissimilarity(
             "Web Database Applications",
             "Building Database Applications on the Web Using PHP3"),
         0.0000)
     self.assertEqual(
         smart_match.dissimilarity(
             "Web Database Applications",
             "Building Web Database Applications with Visual Studio 6"),
         0.0000)
コード例 #27
0
 def test_dissimilarity(self):
     self.assertEqual(smart_match.dissimilarity('hello', 'low'), 0.6)
コード例 #28
0
 def test_dissimilarity(self):
     self.assertAlmostEqual(smart_match.dissimilarity('hello', 'hero'),
                            0.43305329048615915)
コード例 #29
0
    def test_dissimilarity(self):
        self.assertAlmostEqual(
            smart_match.dissimilarity('test string1', 'test string2'),
            0.04166666666666663)
        smart_match.set_params(gap=-1, mismatch=-1, match=1)
        self.assertAlmostEqual(smart_match.dissimilarity('GATTACA', 'GCATGCU'),
                               0.5)
        self.assertAlmostEqual(smart_match.dissimilarity('a b c d', 'a b c e'),
                               0.1428571428571429)
        self.assertAlmostEqual(smart_match.dissimilarity('Healed', 'Sealed'),
                               0.16666666666666663)
        self.assertAlmostEqual(smart_match.dissimilarity('Healed', 'Healthy'),
                               0.4285714285714286)
        self.assertAlmostEqual(smart_match.dissimilarity('Healed', 'Heard'),
                               0.33333333333333337)
        self.assertAlmostEqual(smart_match.dissimilarity('Healed', 'Help'),
                               0.5)
        self.assertAlmostEqual(smart_match.dissimilarity('Healed', 'Sold'),
                               0.6666666666666667)
        self.assertAlmostEqual(smart_match.dissimilarity('Healed', 'Help'),
                               0.5)
        self.assertAlmostEqual(
            smart_match.dissimilarity('Sam J Chapman', 'Samuel John Chapman'),
            0.3157894736842105)
        self.assertAlmostEqual(
            smart_match.dissimilarity('Sam Chapman', 'S Chapman'),
            0.18181818181818177)
        self.assertAlmostEqual(
            smart_match.dissimilarity('John Smith', 'Samuel John Chapman'),
            0.7105263157894737)
        self.assertAlmostEqual(
            smart_match.dissimilarity('John Smith', 'Sam Chapman'),
            0.9090909090909091)
        self.assertAlmostEqual(
            smart_match.dissimilarity('John Smith', 'Sam J Chapman'),
            0.8461538461538461)
        self.assertAlmostEqual(
            smart_match.dissimilarity('John Smith', 'S Chapman'), 0.85)
        self.assertAlmostEqual(
            smart_match.dissimilarity(
                'Web Database Applications',
                'Web Database Applications with PHP & MySQL'),
            0.40476190476190477)
        self.assertAlmostEqual(
            smart_match.dissimilarity(
                'Web Database Applications',
                'Creating Database Web Applications with PHP and ASP'),
            0.5490196078431373)
        self.assertAlmostEqual(
            smart_match.dissimilarity(
                'Web Database Applications',
                'Building Database Applications on the Web Using PHP3'),
            0.57692307692307693)
        self.assertAlmostEqual(
            smart_match.dissimilarity(
                'Web Database Applications',
                'Building Web Database Applications with Visual Studio 6'),
            0.5454545454545454)
        self.assertAlmostEqual(
            smart_match.dissimilarity('Web Database Applications',
                                      'Web Application Development With PHP'),
            0.7083333333333333)

        self.assertAlmostEqual(
            smart_match.dissimilarity(
                'Web Database Applications',
                'WebRAD: Building Database Applications on the'
                ' Web with Visual FoxPro and Web Connection'),
            0.7126436781609196)
        self.assertAlmostEqual(
            smart_match.dissimilarity(
                'Web Database Applications',
                'Structural Assessment: The Role of Large and'
                ' Full-Scale Testing'), 0.8333333333333334)
        self.assertAlmostEqual(
            smart_match.dissimilarity('Web Database Applications',
                                      'How to Find a Scholarship Online'),
            0.828125)
        self.assertAlmostEqual(
            smart_match.dissimilarity(
                'Web Aplications',
                'Web Database Applications with PHP & MySQL'),
            0.6428571428571428)
コード例 #30
0
 def test_dissimilarity(self):
     self.assertAlmostEqual(smart_match.dissimilarity('test string1', 'test string2'), 0.04166666666666663)
     smart_match.set_params(gap=-1, mismatch=-1, match=1)
     self.assertAlmostEqual(smart_match.dissimilarity('GATTACA', 'GCATGCU'), 0.5)