def test_similarity(self):
     self.assertAlmostEqual(smart_match.similarity('test', 'test string1'),
                            0.5773502691896257)
     smart_match.set_params(level='term')
     self.assertAlmostEqual(smart_match.similarity('test', 'test string2'),
                            0.7071067811865475)
Example #2
0
 def test_jaro_sinkler_similarity1(self):
     self.assertAlmostEqual(smart_match.similarity('DwAyNE', 'DuANE'), 0.84)
     self.assertAlmostEqual(smart_match.similarity('TRATE', 'TRACE'),
                            0.9066666666666667)
Example #3
0
 def test_similarity(self):
     self.assertEqual(smart_match.similarity('hello', 'low'), 0.4)
    def test_similarity(self):
        self.assertAlmostEqual(smart_match.similarity('abbcccdd', 'aaabccee'), 0.5)
        self.assertAlmostEqual(smart_match.similarity('hello', 'hollow'), 0.7272727272727273)

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

        smart_match.set_params(level=2)
        self.assertAlmostEqual(smart_match.similarity('test', 'test string2'), 0.5)
        self.assertAlmostEqual(smart_match.similarity('test string1', 'test string2'), 0.8888888888888888)
        self.assertAlmostEqual(smart_match.similarity('Healed', 'Sealed'), 0.8)
        self.assertAlmostEqual(smart_match.similarity('Healed', 'Healthy'), 0.5454545454545454)
        self.assertAlmostEqual(smart_match.similarity('Healed', 'Heard'), 0.4444444444444444)
        self.assertAlmostEqual(smart_match.similarity('Healed', 'Herded'), 0.4)
        self.assertAlmostEqual(smart_match.similarity('Healed', 'Help'), 0.25)
        self.assertAlmostEqual(smart_match.similarity('Healed', 'sold'), 0.0)
        self.assertAlmostEqual(smart_match.similarity('Sam J Chapman', 'Samuel John Chapman'),0.7272727272727273)
        self.assertAlmostEqual(smart_match.similarity('Sam Chapman', 'S Chapman'), 0.8571428571428571)
        self.assertAlmostEqual(smart_match.similarity('John Smith', 'Samuel John Chapman'),0.2857142857142857)
        self.assertAlmostEqual(smart_match.similarity('John Smith', 'Sam Chapman'), 0.0)
        self.assertAlmostEqual(smart_match.similarity('John Smith', 'Sam J Chapman'), 0.0)
        self.assertAlmostEqual(smart_match.similarity('John Smith', 'S Chapman'), 0.0)
        self.assertAlmostEqual(smart_match.similarity('Web Database Applications', 'Web Database Applications with PHP & MySQL'),0.8163265306122449)
        self.assertAlmostEqual(smart_match.similarity('Web Database Applications', 'Creating Database Web Applications with PHP and ASP'),0.7142857142857143)
        self.assertAlmostEqual(smart_match.similarity('Web Database Applications', 'Building Database Applications on the Web Using PHP3'),0.7017543859649122)
        self.assertAlmostEqual(smart_match.similarity('Web Database Applications','Building Web Database Applications with Visual Studio 6'),0.6666666666666666)
        self.assertAlmostEqual(smart_match.similarity('Web Database Applications', 'Web Application Development With PHP'),0.5106382978723404)
        self.assertAlmostEqual(smart_match.similarity('Web Database Applications','WebRAD: Building Database Applications on the Web with Visual FoxPro and Web Connection'),0.4878048780487805)
        self.assertAlmostEqual(smart_match.similarity('Web Database Applications','Structural Assessment: The Role of Large and Full-Scale Testing'),0.09090909090909091)
        self.assertAlmostEqual(smart_match.similarity('Web Database Applications', 'How to Find a Scholarship Online'),0.04878048780487805)
        self.assertAlmostEqual(smart_match.similarity('Web Aplications', 'Web Database Applications with PHP & MySQL'),0.5853658536585366)
        self.assertAlmostEqual(smart_match.similarity('Web Aplications', 'Creating Database Web Applications with PHP and ASP'), 0.5)
        self.assertAlmostEqual(smart_match.similarity('Web Aplications', 'Building Database Applications on the Web Using PHP3'),0.4897959183673469)
        self.assertAlmostEqual(smart_match.similarity('Web Aplications', 'Building Web Database Applications with Visual Studio 6'),0.46153846153846156)
        self.assertAlmostEqual(smart_match.similarity('Web Aplications', 'Web Application Development With PHP'),0.5641025641025641)
        self.assertAlmostEqual(smart_match.similarity('Web Aplications','WebRAD: Building Database Applications on the Web with Visual FoxPro and Web Connection'),0.32432432432432434)
        self.assertAlmostEqual(smart_match.similarity('Web Aplications','Structural Assessment: The Role of Large and Full-Scale Testing'),0.06896551724137931)
        self.assertAlmostEqual(smart_match.similarity('Web Aplications', 'How to Find a Scholarship Online'),0.06060606060606061)
 def test_similarity(self):
     self.assertEqual(smart_match.similarity('hello', 'hero'), 0.6)
     self.assertEqual(smart_match.similarity('Subsitute', 'Subsytute'),
                      0.8888888888888888)
     self.assertEqual(smart_match.similarity('Subsitute', 'Sybsytyte'),
                      0.6666666666666667)
     self.assertEqual(smart_match.similarity('abc', 'abcdef'), 0.5)
     self.assertEqual(smart_match.similarity('def', 'abcdef'), 0.5)
     self.assertEqual(
         smart_match.similarity('test string1', 'test string2'),
         0.9166666666666666)
     self.assertEqual(smart_match.similarity('test', 'test string2'),
                      0.33333333333333337)
     self.assertEqual(smart_match.similarity('', 'test string2'), 0.0)
     self.assertEqual(
         smart_match.similarity('aaa bbb ccc ddd', 'aaa bbb ccc eee'), 0.8)
     self.assertEqual(smart_match.similarity('aaa bbb', 'aaa aaa'),
                      0.5714285714285714)
     self.assertEqual(smart_match.similarity('aaa', 'aaa aaa'),
                      0.4285714285714286)
     self.assertEqual(smart_match.similarity('a b c d', 'a b c e'),
                      0.8571428571428572)
     self.assertEqual(smart_match.similarity('Healed', 'Sealed'),
                      0.8333333333333334)
     self.assertEqual(smart_match.similarity('Healed', 'Healthy'),
                      0.5714285714285714)
     self.assertEqual(smart_match.similarity('Healed', 'Heard'),
                      0.6666666666666667)
     self.assertEqual(smart_match.similarity('Healed', 'Herded'),
                      0.6666666666666667)
     self.assertEqual(smart_match.similarity('Healed', 'Help'), 0.5)
     self.assertEqual(smart_match.similarity('Healed', 'Sold'),
                      0.33333333333333337)
     self.assertEqual(smart_match.similarity('Healed', 'Help'), 0.5)
     self.assertEqual(
         smart_match.similarity('Sam J Chapman', 'Samuel John Chapman'),
         0.6842105263157895)
     self.assertEqual(smart_match.similarity('Sam Chapman', 'S Chapman'),
                      0.8181818181818181)
     self.assertEqual(
         smart_match.similarity('John Smith', 'Samuel John Chapman'),
         0.26315789473684215)
     self.assertEqual(smart_match.similarity('John Smith', 'Sam Chapman'),
                      0.0)
     self.assertEqual(smart_match.similarity('John Smith', 'Sam J Chapman'),
                      0.07692307692307687)
     self.assertEqual(smart_match.similarity('John Smith', 'S Chapman'),
                      0.09999999999999998)
     self.assertEqual(
         smart_match.similarity(
             'Web Database Applications',
             'Web Database Applications with PHP & MySQL'),
         0.5952380952380952)
     self.assertEqual(
         smart_match.similarity(
             'Web Database Applications',
             'Creating Database Web Applications with PHP and ASP'),
         0.4509803921568627)
     self.assertEqual(
         smart_match.similarity(
             'Web Database Applications',
             'Building Database Applications on the Web Using PHP3'),
         0.42307692307692313)
     self.assertEqual(
         smart_match.similarity(
             'Web Database Applications',
             'Building Web Database Applications with Visual Studio 6'),
         0.4545454545454546)
     self.assertEqual(
         smart_match.similarity('Web Database Applications',
                                'Web Application Development With PHP'),
         0.25)
     self.assertEqual(
         smart_match.similarity(
             'Web Database Applications',
             'WebRAD: Building Database Applications on the Web with Visual FoxPro and Web Connection'
         ), 0.28735632183908044)
     self.assertEqual(
         smart_match.similarity(
             'Web Database Applications',
             'Structural Assessment: The Role of Large and Full-Scale Testing'
         ), 0.15873015873015872)
     self.assertEqual(
         smart_match.similarity('Web Database Applications',
                                'How to Find a Scholarship Online'),
         0.15625)
     self.assertEqual(
         smart_match.similarity(
             'Web Aplications',
             'Web Database Applications with PHP & MySQL'),
         0.3571428571428571)
     self.assertEqual(
         smart_match.similarity(
             'Web Aplications',
             'Creating Database Web Applications with PHP and ASP'),
         0.2941176470588235)
     self.assertEqual(
         smart_match.similarity(
             'Web Aplications',
             'Building Database Applications on the Web Using PHP3'), 0.25)
     self.assertEqual(
         smart_match.similarity(
             'Web Aplications',
             'Building Web Database Applications with Visual Studio 6'),
         0.2727272727272727)
     self.assertEqual(
         smart_match.similarity('Web Aplications',
                                'Web Application Development With PHP'),
         0.38888888888888884)
     self.assertEqual(
         smart_match.similarity(
             'Web Aplications',
             'WebRAD: Building Database Applications on the Web with Visual FoxPro and Web Connection'
         ), 0.1724137931034483)
     self.assertEqual(
         smart_match.similarity(
             'Web Aplications',
             'Structural Assessment: The Role of Large and Full-Scale Testing'
         ), 0.11111111111111116)
     self.assertEqual(
         smart_match.similarity('Web Aplications',
                                'How to Find a Scholarship Online'), 0.1875)
 def test_similarity(self):
     self.assertAlmostEqual(smart_match.similarity(['Hello', 'world'], ['Hero', 'world']), 0.8)
     smart_match.set_params(method='cos')
     self.assertAlmostEqual(smart_match.similarity(['Hello', 'world'], ['Hero', 'world']), 0.7834733547569204)
     smart_match.set_params(method='EX', level='term')
     self.assertAlmostEqual(smart_match.similarity('test string1', 'test string2'), 0.5)
     self.assertAlmostEqual(smart_match.similarity('test', 'test string2'), 0.7071067811865476)
     self.assertAlmostEqual(smart_match.similarity('', 'test string2'), 0.0)
     self.assertAlmostEqual(smart_match.similarity('aaa bbb ccc ddd', 'aaa bbb ccc eee'), 0.75)
     self.assertAlmostEqual(smart_match.similarity('a b c d', 'a b c e'), 0.75)
     self.assertAlmostEqual(smart_match.similarity('Sam J Chapman', 'Samuel John Chapman'), 0.3333333333333333)
     self.assertAlmostEqual(smart_match.similarity('Sam Chapman', 'S  Chapman'), 0.5)
     self.assertAlmostEqual(smart_match.similarity('John Smith', 'Samuel John Chapman'), 0.408248290463863)
     self.assertAlmostEqual(smart_match.similarity('John Smith', 'Sam Chapman'), 0.0000)
     self.assertAlmostEqual(smart_match.similarity('John Smith', 'Sam J Chapman'), 0.0000)
     self.assertAlmostEqual(smart_match.similarity('John Smith', 'S Chapman'), 0.0000)
Example #7
0
    def test_similarity(self):
        self.assertEqual(smart_match.similarity('hello', 'hill'), 0.6)
        self.assertEqual(
            smart_match.similarity('test string1', 'test string2'),
            0.9166666666666666)
        self.assertEqual(smart_match.similarity('test', 'test string2'),
                         0.3333333333333333)
        self.assertEqual(smart_match.similarity('', 'test string2'), 0.0)
        self.assertEqual(
            smart_match.similarity('aaa bbb ccc ddd', 'aaa bbb ccc eee'), 0.8)
        self.assertEqual(smart_match.similarity('aaa bbb', 'aaa aaa'),
                         0.5714285714285714)
        self.assertEqual(smart_match.similarity('aaa', 'aaa aaa'),
                         0.42857142857142855)
        self.assertEqual(smart_match.similarity('a b c d', 'a b c e'),
                         0.8571428571428571)
        self.assertEqual(smart_match.similarity('uxaayw', 'uyxw'), 0.5)
        self.assertEqual(smart_match.similarity('uxyw', 'uyxw'), 0.75)
        self.assertEqual(smart_match.similarity('transpose', 'tranpsose'),
                         0.8888888888888888)
        self.assertEqual(smart_match.similarity('Healed', 'Sealed'),
                         0.8333333333333334)
        self.assertEqual(smart_match.similarity('Healed', 'Healthy'),
                         0.5714285714285714)

        self.assertEqual(
            smart_match.similarity(
                'Web Database Applications',
                'Web Database Applications with PHP & MySQL'),
            0.5952380952380952)
        self.assertEqual(
            smart_match.similarity(
                'Web Database Applications',
                'Building Database Applications on the Web Using PHP3'),
            0.4230769230769231)
        self.assertEqual(
            smart_match.similarity(
                'Web Database Applications',
                'Building Web Database Applications with Visual Studio 6'),
            0.45454545454545453)

        self.assertEqual(smart_match.similarity('Healed', 'Heard'),
                         0.6666666666666666)
        self.assertEqual(smart_match.similarity('Healed', 'Herded'),
                         0.6666666666666666)
        self.assertEqual(smart_match.similarity('Healed', 'Help'), 0.5)
        self.assertEqual(smart_match.similarity('Healed', 'sold'),
                         0.3333333333333333)
        self.assertEqual(
            smart_match.similarity('Sam J Chapman', 'Samuel John Chapman'),
            0.6842105263157895)
        self.assertEqual(smart_match.similarity('Sam Chapman', 'S Chapman'),
                         0.8181818181818182)
        self.assertEqual(
            smart_match.similarity('John Smith', 'Samuel John Chapman'),
            0.3157894736842105)
        self.assertEqual(smart_match.similarity('John Smith', 'Sam Chapman'),
                         0.2727272727272727)
        self.assertEqual(smart_match.similarity('John Smith', 'Sam J Chapman'),
                         0.23076923076923078)
        self.assertEqual(smart_match.similarity('John Smith', 'S Chapman'),
                         0.2)
        self.assertEqual(
            smart_match.similarity(
                'Web Database Applications',
                'Creating Database Web Applications with PHP and ASP'),
            0.45098039215686275)
        self.assertEqual(
            smart_match.similarity('Web Database Applications',
                                   'Web Application Development With PHP'),
            0.4166666666666667)
        self.assertEqual(
            smart_match.similarity(
                'Web Database Applications',
                'WebRAD: Building Database Applications on the Web with Visual FoxPro and Web Connection'
            ), 0.28735632183908044)
        self.assertEqual(
            smart_match.similarity(
                'Web Database Applications',
                'Structural Assessment: The Role of Large and Full-Scale Testing'
            ), 0.1746031746031746)
        self.assertEqual(
            smart_match.similarity('Web Database Applications',
                                   'How to Find a Scholarship Online'),
            0.28125)
        self.assertEqual(
            smart_match.similarity(
                'Web Aplications',
                'Web Database Applications with PHP & MySQL'),
            0.35714285714285715)
        self.assertEqual(
            smart_match.similarity(
                'Web Aplications',
                'Creating Database Web Applications with PHP and ASP'),
            0.29411764705882354)
        self.assertEqual(
            smart_match.similarity(
                'Web Aplications',
                'Building Database Applications on the Web Using PHP3'), 0.25)
        self.assertEqual(
            smart_match.similarity(
                'Web Aplications',
                'Building Web Database Applications with Visual Studio 6'),
            0.2727272727272727)
        self.assertEqual(
            smart_match.similarity('Web Aplications',
                                   'Web Application Development With PHP'),
            0.3888888888888889)
        self.assertEqual(
            smart_match.similarity(
                'Web Aplications',
                'WebRAD: Building Database Applications on the Web with Visual FoxPro and Web Connection'
            ), 0.1724137931034483)
        self.assertEqual(
            smart_match.similarity(
                'Web Aplications',
                'Structural Assessment: The Role of Large and Full-Scale Testing'
            ), 0.12698412698412698)
        self.assertEqual(
            smart_match.similarity('Web Aplications',
                                   'How to Find a Scholarship Online'), 0.1875)
 def test_similarity(self):
     self.assertEqual(smart_match.similarity('hello', 'low'), 0.4)
     self.assertEqual(
         smart_match.similarity('test string1', 'test string2'),
         0.9166666666666666)
     self.assertEqual(smart_match.similarity('test', 'test string2'),
                      0.3333333333333333)
     self.assertEqual(smart_match.similarity('', 'test string2'), 0.0)
     self.assertEqual(
         smart_match.similarity('aaa bbb ccc ddd', 'aaa bbb ccc eee'), 0.8)
     self.assertEqual(smart_match.similarity('aaa bbb', 'aaa aaa'),
                      0.5714285714285714)
     self.assertEqual(smart_match.similarity('aaa', 'aaa aaa'),
                      0.42857142857142855)
     self.assertEqual(smart_match.similarity('a b c d', 'a b c e'),
                      0.8571428571428571)
     self.assertEqual(smart_match.similarity('uxyw', 'uyxw'), 0.25)
     self.assertEqual(smart_match.similarity('uxaayw', 'uyxw'),
                      0.16666666666666666)
     self.assertEqual(smart_match.similarity('transpose', 'tranpsose'),
                      0.4444444444444444)
     self.assertEqual(smart_match.similarity('Healed', 'Sealed'),
                      0.8333333333333334)
     self.assertEqual(smart_match.similarity('Healed', 'Healthy'),
                      0.5714285714285714)
     self.assertEqual(smart_match.similarity('Healed', 'Heard'), 0.5)
     self.assertEqual(smart_match.similarity('Healed', 'Help'),
                      0.3333333333333333)
     self.assertEqual(smart_match.similarity('Healed', 'Sold'),
                      0.16666666666666666)
     self.assertEqual(
         smart_match.similarity('Sam J Chapman', 'Samuel John Chapman'),
         0.42105263157894735)
     self.assertEqual(smart_match.similarity('Sam Chapman', 'S Chapman'),
                      0.7272727272727273)
     self.assertEqual(
         smart_match.similarity('John Smith', 'Samuel John Chapman'),
         0.2631578947368421)
     self.assertEqual(smart_match.similarity('John Smith', 'Sam Chapman'),
                      0.09090909090909091)
     self.assertEqual(smart_match.similarity('John Smith', 'Sam J Chapman'),
                      0.07692307692307693)
     self.assertEqual(smart_match.similarity('John Smith', 'S Chapman'),
                      0.1)
     self.assertEqual(
         smart_match.similarity(
             'Web Database Applications',
             'Web Database Applications with PHP & MySQL'),
         0.5952380952380952)
     self.assertEqual(
         smart_match.similarity(
             'Web Database Applications',
             'Creating Database Web Applications with PHP and ASP'),
         0.2549019607843137)
     self.assertEqual(
         smart_match.similarity(
             'Web Database Applications',
             'Building Database Applications on the Web Using PHP3'),
         0.4230769230769231)
     self.assertEqual(
         smart_match.similarity(
             'Web Database Applications',
             'Building Web Database Applications with Visual Studio 6'),
         0.45454545454545453)
     self.assertEqual(
         smart_match.similarity('Web Database Applications',
                                'Web Application Development With PHP'),
         0.3333333333333333)
     self.assertEqual(
         smart_match.similarity(
             'Web Database Applications',
             'WebRAD: Building Database Applications on the Web with Visual FoxPro and Web Connection'
         ), 0.25287356321839083)
     self.assertEqual(
         smart_match.similarity(
             'Web Database Applications',
             'Structural Assessment: The Role of Large and Full-Scale Testing'
         ), 0.031746031746031744)
     self.assertEqual(
         smart_match.similarity('Web Database Applications',
                                'How to Find a Scholarship Online'), 0.0625)
     self.assertEqual(
         smart_match.similarity(
             'Web Aplications',
             'Web Database Applications with PHP & MySQL'),
         0.23809523809523808)
     self.assertEqual(
         smart_match.similarity(
             'Web Aplications',
             'Creating Database Web Applications with PHP and ASP'),
         0.19607843137254902)
     self.assertEqual(
         smart_match.similarity(
             'Web Aplications',
             'Building Database Applications on the Web Using PHP3'),
         0.19230769230769232)
     self.assertEqual(
         smart_match.similarity(
             'Web Aplications',
             'Building Web Database Applications with Visual Studio 6'),
         0.18181818181818182)
     self.assertEqual(
         smart_match.similarity('Web Aplications',
                                'Web Application Development With PHP'),
         0.25)
     self.assertEqual(
         smart_match.similarity(
             'Web Aplications',
             'WebRAD: Building Database Applications on the Web with Visual FoxPro and Web Connection'
         ), 0.11494252873563218)
     self.assertEqual(
         smart_match.similarity(
             'Web Aplications',
             'Structural Assessment: The Role of Large and Full-Scale Testing'
         ), 0.031746031746031744)
     self.assertEqual(
         smart_match.similarity('Web Aplications',
                                'How to Find a Scholarship Online'), 0.0625)
    def test_similarity(self):
        self.assertAlmostEqual(float('%.4f' %smart_match.similarity('DwAyNE', 'DuANE')), 0.84)
        self.assertAlmostEqual(float('%.4f' %smart_match.similarity('TRATE', 'TRACE')), 0.9067)
        self.assertAlmostEqual(float('%.4f' %smart_match.similarity("test string1", "test string2")),0.9667)#0.9484848484848484
        self.assertAlmostEqual(float('%.4f' %smart_match.similarity("", "test string2")),0.0000)
        self.assertAlmostEqual(float('%.4f' %smart_match.similarity("aaa bbb ccc ddd", "aaa bbb ccc eee")),0.9200)
        self.assertAlmostEqual(float('%.4f' %smart_match.similarity("a b c d", "a b c e")),0.9429)
        self.assertAlmostEqual(float('%.4f' %smart_match.similarity("Healed", "Sealed")),0.8889)
        self.assertAlmostEqual(float('%.4f' %smart_match.similarity("Healed", "Healthy")),0.8476)
        self.assertAlmostEqual(float('%.4f' %smart_match.similarity("Healed", "Heard")),0.8756)
        self.assertAlmostEqual(float('%.4f' %smart_match.similarity( "Healed", "Help")),.8000)
        self.assertAlmostEqual(float('%.4f' %smart_match.similarity("Healed", "Sold")),0.6111)
        self.assertAlmostEqual(float('%.4f' %smart_match.similarity( "Healed", "Help")),0.8000)
        self.assertAlmostEqual(float('%.4f' %smart_match.similarity("Sam Chapman", "S Chapman")),0.8288) #0.8455
        self.assertAlmostEqual(float('%.4f' % smart_match.similarity("John Smith", "Samuel John Chapman")),0.5945)
        self.assertAlmostEqual(float('%.4f' %smart_match.similarity("John Smith", "Sam Chapman")),0.4131)
        self.assertAlmostEqual(float('%.4f' %smart_match.similarity("John Smith", "Sam J Chapman")),0.4949)
        self.assertAlmostEqual(float('%.4f' %smart_match.similarity("John Smith", "S Chapman")),0.4333)
        self.assertAlmostEqual(float('%.4f' %smart_match.similarity("Web Database Applications",
            "Web Database Applications with PHP & MySQL")),0.9190)
        self.assertAlmostEqual(float('%.4f' %smart_match.similarity("Web Database Applications",
            "Creating Database Web Applications with PHP and ASP")),0.6901)
        self.assertAlmostEqual(float('%.4f' %smart_match.similarity("Web Database Applications",
            "Building Database Applications on the Web Using PHP3")),0.6353)
        self.assertAlmostEqual(float('%.4f' %smart_match.similarity("Web Database Applications",
            "Building Web Database Applications with Visual Studio 6")),0.6582)

        smart_match.set_params(boost_threshold=0.6)
        self.assertAlmostEqual(float('%.4f' % smart_match.similarity('abcdefgh', 'abehc')), 0.7467)
        self.assertAlmostEqual(float('%.4f' %smart_match.similarity("Healed", "Herded")),0.7556)
        self.assertAlmostEqual(float('%.4f' % smart_match.similarity("Web Database Applications",
            "Web Application Development With PHP")),0.7786)  # 0.631
Example #10
0
 def test_jaro_similarity1(self):
     self.assertAlmostEqual(smart_match.similarity('ABC', 'CBA'),
                            0.5555555555555555)
Example #11
0
    def test_similarity(self):
        self.assertEqual(smart_match.similarity('hello', 'hero'), 0.6)
        self.assertEqual(float('%.4f' %smart_match.similarity("test string1", "test string2")), 0.9167)
        self.assertEqual(smart_match.similarity("", "test string2"),0.0000)
        self.assertEqual(smart_match.similarity( "aaa bbb ccc ddd", "aaa bbb ccc eee"),0.8000)
        self.assertEqual(float('%.4f' %smart_match.similarity("aaa bbb", "aaa aaa")),0.5714)
        self.assertEqual(float('%.4f' %smart_match.similarity("aaa", "aaa aaa")),0.4286)
        self.assertEqual(float('%.4f' %smart_match.similarity("a b c d", "a b c e")),0.8571)
        self.assertEqual(float('%.4f' %smart_match.similarity("uxyw", "uyxw")),0.7500)
        self.assertEqual(float('%.4f' %smart_match.similarity("uxaayw", "uyxw")),0.3333)
        self.assertEqual(float('%.4f' %smart_match.similarity("transpose", "tranpsose")),0.8889)
        self.assertEqual(float('%.4f' %smart_match.similarity("Healed", "Sealed")),0.8333)
        self.assertEqual(float('%.4f' %smart_match.similarity("Healed", "Healthy")),0.5714)
        self.assertEqual(float('%.4f' %smart_match.similarity("Healed", "Heard")),0.6667)
        self.assertEqual(float('%.4f' %smart_match.similarity("Healed", "Herded")),0.6667)
        self.assertEqual(float('%.4f' %smart_match.similarity("Healed", "Help")),0.5000)
        self.assertEqual(float('%.4f' %smart_match.similarity("Healed", "Sold")),0.3333)
        self.assertEqual(float('%.4f' %smart_match.similarity("Healed", "Help")),0.5000)
        self.assertEqual(float('%.4f' %smart_match.similarity("Sam J Chapman", "Samuel John Chapman")),0.6842)
        self.assertEqual(float('%.4f' %smart_match.similarity("Sam Chapman", "S Chapman")),0.8182)
        self.assertEqual(float('%.4f' %smart_match.similarity("John Smith", "Samuel John Chapman")),0.2632)
        self.assertEqual(float('%.4f' %smart_match.similarity("John Smith", "Sam Chapman")),0.0000)
        self.assertEqual(float('%.4f' %smart_match.similarity("John Smith", "Sam J Chapman")),0.0769)
        self.assertEqual(float('%.4f' %smart_match.similarity("John Smith", "S Chapman")),0.1000)
        self.assertEqual(float('%.4f' %smart_match.similarity("Web Database Applications",
        "Web Database Applications with PHP & MySQL")),0.5952)
        self.assertEqual(float('%.4f' %smart_match.similarity("Web Database Applications",
        "Creating Database Web Applications with PHP and ASP")),0.4510)
        self.assertEqual(float('%.4f' %smart_match.similarity("Web Database Applications",
        "Building Database Applications on the Web Using PHP3")),0.4231)
        self.assertEqual(float('%.4f' %smart_match.similarity("Web Database Applications",
        "Building Web Database Applications with Visual Studio 6")),0.4545)
        self.assertEqual(float('%.4f' %smart_match.similarity("Web Database Applications",
        "Web Application Development With PHP")),0.2500)
        self.assertEqual(float('%.4f' %smart_match.similarity("Web Database Applications",
        "WebRAD: Building Database Applications on the Web with Visual FoxPro and Web Connection")),
            0.2874)
        self.assertEqual(float('%.4f' %smart_match.similarity("Web Database Applications",
            "Structural Assessment: The Role of Large and Full-Scale Testing")),0.1587)
        self.assertEqual(float('%.4f' %smart_match.similarity("Web Database Applications",
            "How to Find a Scholarship Online")),0.1562)
        self.assertEqual(float('%.4f' %smart_match.similarity("Web Aplications",
            "Web Database Applications with PHP & MySQL")),0.3571)
        self.assertEqual(float('%.4f' %smart_match.similarity("Web Aplications",
            "Creating Database Web Applications with PHP and ASP")),0.2941)
        self.assertEqual(float('%.4f' %smart_match.similarity("Web Aplications",
            "Building Database Applications on the Web Using PHP3")),0.2500)
        self.assertEqual(float('%.4f' %smart_match.similarity("Web Aplications",
            "Building Web Database Applications with Visual Studio 6")),0.2727)
        self.assertEqual(float('%.4f' %smart_match.similarity("Web Aplications",
            "Web Application Development With PHP")),0.3889)
        self.assertEqual(float('%.4f' %smart_match.similarity("Web Aplications",
            "WebRAD: Building Database Applications on the Web with Visual FoxPro and Web Connection")),
            0.1724)
        self.assertEqual(float('%.4f' %smart_match.similarity("Web Aplications",
            "Structural Assessment: The Role of Large and Full-Scale Testing")),0.1111)

        self.assertEqual(float('%.4f' %smart_match.similarity("Web Aplications",
            "How to Find a Scholarship Online")),0.1875)
        self.assertEqual(float('%.4f' %smart_match.similarity( "uxyw", "")),0.0000)
Example #12
0
 def test_jaro_similarity4(self):
     self.assertAlmostEqual(
         smart_match.similarity('AABABCAAAC', 'ABAACBAAAC'),
         0.9333333333333332)
Example #13
0
 def test_jaro_similarity3(self):
     self.assertAlmostEqual(smart_match.similarity('CRATE', 'TRACE'),
                            0.7333333333333334)
 def test_similarity(self):
     self.assertAlmostEqual(
         smart_match.similarity('Web Aplications',
                                'Web Application Development With PHP'),
         0.8666666666666667)
    def test_similarity(self):
        self.assertAlmostEqual(smart_match.similarity('hello', 'hero'), 0.5669467095138409)
        smart_match.set_params(level='term')
        self.assertAlmostEqual(smart_match.similarity('test string1', 'test string2'), 0.5)
        self.assertAlmostEqual(smart_match.similarity('test', 'test string2'), 0.7071067811865475)
        self.assertAlmostEqual(smart_match.similarity('aaa bbb ccc ddd', 'aaa bbb ccc eee'), 0.75)
        self.assertAlmostEqual(smart_match.similarity('a b c d', 'a b c e'), 0.75)
        self.assertAlmostEqual(smart_match.similarity('a b c d', 'a b e f'), 0.5)
        self.assertAlmostEqual(smart_match.similarity('a b c', 'a b c e f g'), 0.7071067811865476)
        self.assertAlmostEqual(smart_match.similarity('Healed', 'Sealed'), 0.0)
        self.assertAlmostEqual(smart_match.similarity('Healed', 'Healthy'), 0.0)
        self.assertAlmostEqual(smart_match.similarity('Healed', 'Heard'), 0.0)
        self.assertAlmostEqual(smart_match.similarity('Healed', 'Help'), 0.0)
        self.assertAlmostEqual(smart_match.similarity('Healed', 'Sold'), 0.0)
        self.assertAlmostEqual(smart_match.similarity('Healed', 'Help'), 0.0)
        self.assertAlmostEqual(smart_match.similarity('Sam J Chapman', 'Samuel John Chapman'), 0.33333333333333337)
        self.assertAlmostEqual(smart_match.similarity('Sam Chapman', 'S Chapman'), 0.4999999999999999)
        self.assertAlmostEqual(smart_match.similarity('John Smith', 'Samuel John Chapman'), 0.40824829046386296)
        self.assertAlmostEqual(smart_match.similarity('John Smith', 'Sam Chapman'), 0.0)
        self.assertAlmostEqual(smart_match.similarity('John Smith', 'Sam J Chapman'), 0.0)
        self.assertAlmostEqual(smart_match.similarity('John Smith', 'S Chapman'), 0.0)
        self.assertAlmostEqual(smart_match.similarity('Web Database Applications',
                                                      'Web Database Applications with PHP & MySQL'), 0.6546536707079772)
        self.assertAlmostEqual(smart_match.similarity('Web Database Applications',
                                                      'Creating Database Web Applications with PHP and ASP'),
                               0.6123724356957945)
        self.assertAlmostEqual(smart_match.similarity('Web Database Applications',
                                                      'Building Database Applications on the Web Using PHP3'),
                               0.6123724356957945)
        self.assertAlmostEqual(smart_match.similarity('Web Database Applications',
                                                      'Building Web Database Applications with Visual Studio 6'),
                               0.6123724356957945)
        self.assertAlmostEqual(smart_match.similarity('Web Database Applications',
                                                      'Web Application Development With PHP'), 0.2581988897471611)

        self.assertAlmostEqual(smart_match.similarity('Web Database Applications',
                                                      'WebRAD: Building Database Applications on the'
                                                      ' Web with Visual FoxPro and Web Connection'), 0.5962847939999439)
        self.assertAlmostEqual(smart_match.similarity('Web Database Applications',
                                                      'Structural Assessment: The Role of Large and Full-Scale Testing')
                               , 0.0)
        self.assertAlmostEqual(smart_match.similarity('Web Database Applications',
                                                      'How to Find a Scholarship Online'), 0.0)
        self.assertAlmostEqual(smart_match.similarity('Web Aplications',
                                                      'Web Database Applications with PHP & MySQL'), 0.26726124191242434)
 def test_similarity(self):
     self.assertAlmostEqual(smart_match.similarity('hello', 'helo'), 0.8)
Example #17
0
 def test_similarity(self):
     self.assertEqual(smart_match.similarity('12211', '11111'), 0.6)
     self.assertEqual(smart_match.similarity('hello', 'heool'), 0.4)
Example #18
0
 def test_jaro_similarity1(self):
     self.assertAlmostEqual(smart_match.similarity('ABC','CBA'), 0.5555555555555555)
     self.assertAlmostEqual(smart_match.similarity('CRATE','TRACE'), 0.7333333333333334)
     self.assertAlmostEqual(smart_match.similarity('CRATE','TRACE'), 0.7333333333333334)
     self.assertAlmostEqual(smart_match.similarity('AABABCAAAC', 'ABAACBAAAC'), 0.9333333333333332)
 def test_similarity(self):
     self.assertAlmostEqual(smart_match.similarity('GGTTGACTA', 'TGTTACGG'),
                            0.3125)
     smart_match.set_params(gap=-2, match=3, mismatch=-3)
     self.assertAlmostEqual(smart_match.similarity('GGTTGACTA', 'TGTTACGG'),
                            0.2916666666666667)
    def test_similarity(self):
        self.assertAlmostEqual(smart_match.similarity('hello', 'helo'), 0.8)
        self.assertAlmostEqual(smart_match.similarity('abcd', 'abce'), 0.6)
        self.assertAlmostEqual(smart_match.similarity('abcd', 'abef'),
                               0.3333333333333333)
        self.assertAlmostEqual(smart_match.similarity('abc', 'abcefg'), 0.5)
        self.assertAlmostEqual(smart_match.similarity('abbcc', 'abcefg'),
                               0.375)

        smart_match.set_params(level='term')
        self.assertAlmostEqual(
            smart_match.similarity('test string1', 'test string2'),
            0.3333333333333333)
        self.assertAlmostEqual(smart_match.similarity('test', 'test string2'),
                               0.5)
        self.assertAlmostEqual(smart_match.similarity('', 'test string2'), 0)
        self.assertAlmostEqual(
            smart_match.similarity('aaa bbb ccc ddd', 'aaa bbb ccc eee'), 0.6)
        self.assertAlmostEqual(
            smart_match.similarity('aaa bbb ccc ddd aaa bbb ccc ddd',
                                   'aaa bbb ccc eee'), 0.3333333333333333)
        self.assertAlmostEqual(
            smart_match.similarity('Sam J Chapman', 'Samuel John Chapman'),
            0.2)
        self.assertAlmostEqual(
            smart_match.similarity('Sam Chapman', 'S Chapman'),
            0.3333333333333333)
        self.assertAlmostEqual(
            smart_match.similarity('John Smith', 'Samuel John Chapman'), 0.25)
        self.assertAlmostEqual(
            smart_match.similarity('John Smith', 'Sam Chapman'), 0)
        self.assertAlmostEqual(
            smart_match.similarity('John Smith', 'Sam J Chapman'), 0)
        self.assertAlmostEqual(
            smart_match.similarity('John Smith', 'S Chapman'), 0)
        self.assertAlmostEqual(
            smart_match.similarity(
                'Web Database Applications',
                'Web Database Applications with PHP & MySQL'),
            0.42857142857142855)
        self.assertAlmostEqual(
            smart_match.similarity(
                'Web Database Applications',
                'Creating Database Web Applications with PHP and ASP'), 0.3750)
        self.assertAlmostEqual(
            smart_match.similarity(
                'Web Database Applications',
                'Building Database Applications on the Web Using PHP3'),
            0.3750)
        self.assertAlmostEqual(
            smart_match.similarity(
                'Web Database Applications',
                'Building Web Database Applications with Visual Studio 6'),
            0.3750)
        self.assertAlmostEqual(
            smart_match.similarity('Web Database Applications',
                                   'Web Application Development With PHP'),
            0.14285714285714285)
        self.assertAlmostEqual(
            smart_match.similarity(
                'Web Database Applications',
                'WebRAD: Building Database Applications on the Web with Visual FoxPro and Web Connection'
            ), 0.23076923076923078)
        self.assertAlmostEqual(
            smart_match.similarity(
                'Web Database Applications',
                'Structural Assessment: The Role of Large and Full-Scale Testing'
            ), 0)
        self.assertAlmostEqual(
            smart_match.similarity('Web Database Applications',
                                   'How to Find a Scholarship Online'), 0)
        self.assertAlmostEqual(
            smart_match.similarity(
                'Web Aplications',
                'Web Database Applications with PHP & MySQL'), 0.1250)
        self.assertAlmostEqual(
            smart_match.similarity(
                'Web Aplications',
                'Creating Database Web Applications with PHP and ASP'),
            0.1111111111111111)
        self.assertAlmostEqual(
            smart_match.similarity(
                'Web Aplications',
                'Building Database Applications on the Web Using PHP3'),
            0.1111111111111111)
        self.assertAlmostEqual(
            smart_match.similarity(
                'Web Aplications',
                'Building Web Database Applications with Visual Studio 6'),
            0.1111111111111111)
        self.assertAlmostEqual(
            smart_match.similarity('Web Aplications',
                                   'Web Application Development With PHP'),
            0.16666666666666666)
        self.assertAlmostEqual(
            smart_match.similarity(
                'Web Aplications',
                'WebRAD: Building Database Applications on the Web with Visual FoxPro and Web Connection'
            ), 0.07142857142857142)
        self.assertAlmostEqual(
            smart_match.similarity(
                'Web Aplications',
                'Structural Assessment: The Role of Large and Full-Scale Testing'
            ), 0)
        self.assertAlmostEqual(
            smart_match.similarity('Web Aplications',
                                   'How to Find a Scholarship Online'), 0)
        self.assertAlmostEqual(smart_match.similarity('a b c d', 'a b c e'),
                               0.6)
        self.assertAlmostEqual(smart_match.similarity('a b c d', 'a b e f'),
                               0.3333333333333333)
        self.assertAlmostEqual(smart_match.similarity('a b c', 'a b c e f g'),
                               0.5)
        self.assertAlmostEqual(
            smart_match.similarity('a b b c c', 'a b c e f g'), 0.375)

        smart_match.set_params(level='char')
        self.assertAlmostEqual(
            smart_match.similarity(('test', None), ('test', 'string2')),
            0.3333333333333333)
Example #21
0
 def test_similarity(self):
     smart_match.set_params(level='term')
     self.assertAlmostEqual(smart_match.similarity('hello', 'hero'), 0.0)
     self.assertAlmostEqual(smart_match.similarity('hello', 'ehllo'),0.0)
     self.assertAlmostEqual(smart_match.similarity('test string1', 'test string2'), 0.5)
     self.assertAlmostEqual(smart_match.similarity('test','test string2'),0.5527864045000421)
     self.assertAlmostEqual(smart_match.similarity('','test string2'),0.2928932188134524)
     self.assertAlmostEqual(smart_match.similarity('aaa bbb ccc ddd','aaa bbb ccc eee'),0.75)
     self.assertAlmostEqual(smart_match.similarity('a b c d','a b c e'),0.75)
     self.assertAlmostEqual(smart_match.similarity('a b c d','a b c e f'),0.7294991095997703)
     self.assertAlmostEqual(smart_match.similarity('a b c d','a b e f'),0.6464466094067263)
     self.assertAlmostEqual(smart_match.similarity('a b c','a b c e f g'),0.7418011102528389)
     self.assertAlmostEqual(smart_match.similarity('a b b c c','a b c e f g'),0.7137008328430658)
     self.assertAlmostEqual(smart_match.similarity('Healed','Sealed'),0.0)
     self.assertAlmostEqual(smart_match.similarity('Healed','Healthy'),0.0)
     self.assertAlmostEqual(smart_match.similarity('Healed','Heard'),0.0)
     self.assertAlmostEqual(smart_match.similarity('Healed','Herded'),0.0)
     self.assertAlmostEqual(smart_match.similarity('Healed','Help'),0.0)
     self.assertAlmostEqual(smart_match.similarity('Healed','Sold'),0.0)
     self.assertAlmostEqual(smart_match.similarity('Healed','Help'),0.0)
     self.assertAlmostEqual(smart_match.similarity('Healed','So'),0.0)
     self.assertAlmostEqual(smart_match.similarity('Sam J Chapman','Samuel John Chapman'),0.5285954792089682)
     self.assertAlmostEqual(smart_match.similarity('Sam Chapman','S Chapman'),0.5)
     self.assertAlmostEqual(smart_match.similarity('John Smith','Samuel John Chapman'),0.5196155385847385)
     self.assertAlmostEqual(smart_match.similarity('John Smith','Sam Chapman'),0.29289321881345254)
     self.assertAlmostEqual(smart_match.similarity('John Smith','Sam J Chapman'),0.3798263270539577)
     self.assertAlmostEqual(smart_match.similarity('John Smith','S Chapman'),0.29289321881345254)
     self.assertAlmostEqual(smart_match.similarity('Web Database Applications','Web Database Applications with PHP & MySQL'),0.7373871342805549)
     self.assertAlmostEqual(smart_match.similarity('Web Database Applications','Creating Database Web Applications with PHP and ASP'),0.7382880387048931)
     self.assertAlmostEqual(smart_match.similarity('Web Database Applications','Building Database Applications on the Web Using PHP3'),0.7382880387048931)
     self.assertAlmostEqual(smart_match.similarity('Web Database Applications','Building Web Database Applications with Visual Studio 6'),0.7382880387048931)
     self.assertAlmostEqual(smart_match.similarity('Web Database Applications','Web Application Development With PHP'),0.5799159747915972)
     self.assertAlmostEqual(smart_match.similarity('Web Database Applications','WebRAD: Building Database Applications on the Web with Visual FoxPro and Web Connection'),0.7629772684300113)
     self.assertAlmostEqual(smart_match.similarity('Web Database Applications','Structural Assessment: The Role of Large and Full-Scale Testing'),0.6348516283298893)
     self.assertAlmostEqual(smart_match.similarity('Web Database Applications','How to Find a Scholarship Online'),0.5527864045000421)
     self.assertAlmostEqual(smart_match.similarity('Web Aplications','Web Database Applications with PHP & MySQL'),0.6365781078441844)
     self.assertAlmostEqual(smart_match.similarity('Web Aplications','Creating Database Web Applications with PHP and ASP'),0.6570028297149824)
     self.assertAlmostEqual(smart_match.similarity('Web Aplications','Building Database Applications on the Web Using PHP3'),0.6570028297149824)
     self.assertAlmostEqual(smart_match.similarity('Web Aplications','Web Application Development With PHP'),0.5847726007313001)
     self.assertAlmostEqual(smart_match.similarity('Web Aplications','WebRAD: Building Database Applications on the Web with Visual FoxPro and Web Connection'),0.7258750126848699)
     self.assertAlmostEqual(smart_match.similarity('Web Aplications','Structural Assessment: The Role of Large and Full-Scale Testing'),0.6402615329077492)
     self.assertAlmostEqual(smart_match.similarity('Web Aplications','How to Find a Scholarship Online'),0.5527864045000421)
 def test_similarity(self):
     self.assertEqual(smart_match.similarity('hello', 'hero'), 0.75)
     smart_match.set_params(level='term')
     self.assertAlmostEqual(
         smart_match.similarity('test string1', 'test string2'), 0.5)
     self.assertEqual(
         smart_match.similarity("aaa bbb ccc ddd", "aaa bbb ccc eee"),
         0.7500)
     self.assertEqual(
         smart_match.similarity("aaa bbb ccc ddd aaa bbb ccc ddd",
                                "aaa bbb ccc eee"), 0.7500)
     self.assertEqual(smart_match.similarity("a b c d", "a b c e"), 0.7500)
     self.assertEqual(smart_match.similarity("a b c d", "a b e f"), 0.5000)
     self.assertEqual(smart_match.similarity("a b c", "a b c e f g"),
                      1.0000)
     self.assertEqual(smart_match.similarity("a b b c c", "a b c e f g"),
                      1.0000)
     self.assertEqual(smart_match.similarity("Healed", "Sealed"), 0.0000)
     self.assertEqual(smart_match.similarity("Healed", "Healthy"), 0.0000)
     self.assertEqual(smart_match.similarity("Healed", "Heard"), 0.0000)
     self.assertEqual(smart_match.similarity("Healed", "Herded"), 0.0000)
     self.assertEqual(smart_match.similarity("Healed", "Help"), 0.0000)
     self.assertEqual(smart_match.similarity("Healed", "Sold"), 0.0000)
     self.assertEqual(smart_match.similarity("Healed", "Help"), 0.0000)
     self.assertEqual(
         float('%.4f' % smart_match.similarity(
             "Sam J Chapman", "Samuel John Chapman")), 0.3333)
     self.assertEqual(smart_match.similarity("Sam Chapman", "S Chapman"),
                      0.5000)
     self.assertEqual(
         smart_match.similarity("John Smith", "Samuel John Chapman"),
         0.5000)
     self.assertEqual(smart_match.similarity("John Smith", "Sam Chapman"),
                      0.0000)
     self.assertEqual(smart_match.similarity("John Smith", "Sam J Chapman"),
                      0.0000)
     self.assertEqual(smart_match.similarity("John Smith", "S Chapman"),
                      0.0000)
     self.assertEqual(
         smart_match.similarity(
             "Web Database Applications",
             "Web Database Applications with PHP & MySQL"), 1.0000)
     self.assertEqual(
         smart_match.similarity(
             "Web Database Applications",
             "Creating Database Web Applications with PHP and ASP"), 1.0000)
     self.assertEqual(
         smart_match.similarity(
             "Web Database Applications",
             "Building Database Applications on the Web Using PHP3"),
         1.0000)
     self.assertEqual(
         smart_match.similarity(
             "Web Database Applications",
             "Building Web Database Applications with Visual Studio 6"),
         1.0000)
     self.assertEqual(
         float('%.4f' % smart_match.similarity(
             "Web Database Applications",
             "Web Application Development With PHP")), 0.3333)
     self.assertEqual(
         smart_match.similarity(
             "Web Database Applications",
             "WebRAD: Building Database Applications on the Web with Visual FoxPro and Web Connection"
         ), 1.0000)
     self.assertEqual(
         smart_match.similarity(
             "Web Database Applications",
             "Structural Assessment: The Role of Large and Full-Scale Testing"
         ), 0.0000)
     self.assertEqual(
         smart_match.similarity("Web Database Applications",
                                "How to Find a Scholarship Online"), 0.0000)
     self.assertEqual(
         smart_match.similarity(
             "Web Aplications",
             "Web Database Applications with PHP & MySQL"), 0.5000)
     self.assertEqual(
         smart_match.similarity(
             "Web Aplications",
             "Creating Database Web Applications with PHP and ASP"), 0.5000)
     self.assertEqual(
         smart_match.similarity(
             "Web Aplications",
             "Building Database Applications on the Web Using PHP3"),
         0.5000)
     self.assertEqual(
         smart_match.similarity(
             "Web Aplications",
             "Building Web Database Applications with Visual Studio 6"),
         0.5000)
     self.assertEqual(
         smart_match.similarity("Web Aplications",
                                "Web Application Development With PHP"),
         0.5000)
     self.assertEqual(
         smart_match.similarity(
             "Web Aplications",
             "WebRAD: Building Database Applications on the Web with Visual FoxPro and Web Connection"
         ), 0.5000)
     self.assertEqual(
         smart_match.similarity(
             "Web Aplications",
             "Structural Assessment: The Role of Large and Full-Scale Testing"
         ), 0.0000)
     self.assertEqual(
         smart_match.similarity("Web Aplications",
                                "How to Find a Scholarship Online"), 0.0000)
Example #23
0
    def test_similarity(self):
        self.assertAlmostEqual(smart_match.similarity('hello', 'helo'), 1)
        self.assertAlmostEqual(smart_match.similarity('hello', 'hero'), 0.6)
        self.assertAlmostEqual(
            smart_match.similarity('hello world', 'hello world hello world'),
            1)
        smart_match.set_params(level='term')
        self.assertAlmostEqual(
            float('%.4f' %
                  smart_match.similarity('test string1', 'test string2')),
            0.3333)
        self.assertAlmostEqual(smart_match.similarity('test', 'test string2'),
                               0.5000)
        self.assertAlmostEqual(smart_match.similarity('', 'test string2'),
                               0.0000)

        self.assertAlmostEqual(
            smart_match.similarity('aaa bbb ccc ddd', 'aaa bbb ccc eee'),
            0.6000)
        self.assertAlmostEqual(
            smart_match.similarity('aaa bbb ccc ddd aaa bbb ccc ddd',
                                   'aaa bbb ccc eee'), 0.6000)
        self.assertAlmostEqual(smart_match.similarity('a b c d', 'a b c e'),
                               0.6000)
        self.assertAlmostEqual(
            float('%.4f' % smart_match.similarity('a b c d', 'a b e f')),
            0.3333)
        self.assertAlmostEqual(smart_match.similarity('a b c ', 'a b c e f g'),
                               0.5000)
        self.assertAlmostEqual(
            smart_match.similarity('a b b c c', 'a b c e f g'), 0.5000)

        self.assertAlmostEqual(smart_match.similarity('Healed', 'Sealed'),
                               0.0000)
        self.assertAlmostEqual(smart_match.similarity('Healed', 'Healthy'),
                               0.0000)
        self.assertAlmostEqual(smart_match.similarity('Healed', 'Heard'),
                               0.0000)
        self.assertAlmostEqual(smart_match.similarity('Healed', 'Herded'),
                               0.0000)
        self.assertAlmostEqual(smart_match.similarity('Healed', 'Help'),
                               0.0000)
        self.assertAlmostEqual(smart_match.similarity('Healed', 'Sold'),
                               0.0000)

        self.assertAlmostEqual(
            smart_match.similarity('Sam J Chapman', 'Samuel John Chapman'),
            0.2000)
        self.assertAlmostEqual(
            float('%.4f' % smart_match.similarity('Sam Chapman', 'S Chapman')),
            0.3333)
        self.assertAlmostEqual(
            smart_match.similarity('John Smith', 'Samuel John Chapman'),
            0.2500)
        self.assertAlmostEqual(
            smart_match.similarity('John Smith', 'Sam Chapman'), 0.0000)
        self.assertAlmostEqual(
            smart_match.similarity('John Smith', 'Sam J Chapman'), 0.0000)
        self.assertAlmostEqual(
            smart_match.similarity('John Smith', 'S Chapman'), 0.0000)

        self.assertAlmostEqual(
            float('%.4f' % smart_match.similarity(
                'Web Database Applications',
                'Web Database Applications with PHP & MySQL')), 0.4286)
        self.assertAlmostEqual(
            smart_match.similarity(
                'Web Database Applications',
                'Creating Database Web Applications with PHP and ASP'), 0.3750)
        self.assertAlmostEqual(
            smart_match.similarity(
                'Web Database Applications',
                'Building Database Applications on the Web Using PHP3'),
            0.3750)
        self.assertAlmostEqual(
            smart_match.similarity(
                'Web Database Applications',
                'Building Web Database Applications with Visual Studio 6'),
            0.3750)
        self.assertAlmostEqual(
            float('%.4f' % smart_match.similarity(
                'Web Database Applications',
                'Web Application Development With PHP')), 0.1429)
        self.assertAlmostEqual(
            smart_match.similarity(
                'Web Database Applications',
                'WebRAD: Building Database Applications on the Web with Visual FoxPro and Web Connection'
            ), 0.2500)
        self.assertAlmostEqual(
            smart_match.similarity(
                'Web Database Applications',
                'Structural Assessment: The Role of Large and Full-Scale Testing'
            ), 0.0000)
        self.assertAlmostEqual(
            smart_match.similarity('Web Database Applications',
                                   'How to Find a Scholarship Online'), 0.0000)

        self.assertAlmostEqual(
            float('%.4f' % smart_match.similarity(
                'Web  Applications',
                'Web Database Applications with PHP & MySQL')), 0.2857)
        self.assertAlmostEqual(
            smart_match.similarity(
                'Web  Applications',
                'Creating Database Web Applications with PHP and ASP'), 0.2500)
        self.assertAlmostEqual(
            smart_match.similarity(
                'Web  Applications',
                'Building Database Applications on the Web Using PHP3'),
            0.2500)
        self.assertAlmostEqual(
            smart_match.similarity(
                'Web  Applications',
                'Building Web Database Applications with Visual Studio 6'),
            0.2500)
        self.assertAlmostEqual(
            float('%.4f' % smart_match.similarity(
                'Web  Applications', 'Web Application Development With PHP')),
            0.1667)
        self.assertAlmostEqual(
            float('%.4f' % smart_match.similarity(
                'Web  Applications',
                'WebRAD: Building Database Applications on the Web with Visual FoxPro and Web Connection'
            )), 0.1667)
        self.assertAlmostEqual(
            smart_match.similarity(
                'Web  Applications',
                'Structural Assessment: The Role of Large and Full-Scale Testing'
            ), 0.0000)
        self.assertAlmostEqual(
            smart_match.similarity('Web  Applications',
                                   'How to Find a Scholarship Online'), 0.0000)
 def test_similarity(self):
     self.assertAlmostEqual(smart_match.similarity('hello', 'hero'),
                            0.5669467095138409)
    def test_similarity(self):
        self.assertAlmostEqual(float('%.4f' % smart_match.similarity('test', 'test string1')), .5774)
        smart_match.set_params(level='term')
        self.assertAlmostEqual(float('%.4f' % smart_match.similarity("test string1", "test string2")), 0.5000)
        self.assertAlmostEqual(float('%.4f' % smart_match.similarity("test", "test string2")), 0.7071)
        self.assertAlmostEqual(float('%.4f' % smart_match.similarity("", "test string2")), 0.0000)

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

        self.assertAlmostEqual(float('%.4f' % smart_match.similarity("a b c d", "a b c e")), 0.7500)
        self.assertAlmostEqual(float('%.4f' % smart_match.similarity("a b c d", "a b e f")), 0.5000)
        self.assertAlmostEqual(float('%.4f' % smart_match.similarity("a b c", "a b c e f g")), 0.7071)
        self.assertAlmostEqual(float('%.4f' % smart_match.similarity("a b b c c", "a b c e f g")), 0.7071)

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

        self.assertAlmostEqual(float('%.4f' % smart_match.similarity("Sam J Chapman", "Samuel John Chapman")), 0.3333)
        self.assertAlmostEqual(float('%.4f' % smart_match.similarity("Sam Chapman", "S Chapman")), 0.5000)
        self.assertAlmostEqual(float('%.4f' % smart_match.similarity("John Smith", "Samuel John Chapman")), 0.4082)
        self.assertAlmostEqual(float('%.4f' % smart_match.similarity("John Smith", "Sam Chapman")), 0.0000)
        self.assertAlmostEqual(float('%.4f' % smart_match.similarity("John Smith", "Sam J Chapman")), 0.0000)
        self.assertAlmostEqual(float('%.4f' % smart_match.similarity("John Smith", "S Chapman")), 0.0000)

        self.assertAlmostEqual(float('%.4f' % smart_match.similarity("Web Database Applications","Web Database Applications with PHP & MySQL")), 0.6547)
        self.assertAlmostEqual(float('%.4f' % smart_match.similarity("Web Database Applications","Creating Database Web Applications with PHP and ASP")), 0.6124)
        self.assertAlmostEqual(float('%.4f' % smart_match.similarity("Web Database Applications","Structural Assessment: The Role of Large and Full-Scale Testing")), 0.0000)
        self.assertAlmostEqual(float('%.4f' % smart_match.similarity("Web Database Applications","Web Application Development With PHP")), 0.2582)
        self.assertAlmostEqual(float('%.4f' % smart_match.similarity("Web Aplications","Web Application Development With PHP")), 0.3162)
        self.assertAlmostEqual(float('%.4f' % smart_match.similarity("Web Aplications","Web Database Applications with PHP & MySQL")), 0.2673)
Example #26
0
    def test_similarity(self):
        self.assertAlmostEqual(smart_match.similarity('hello', 'hero'), 0.6666666666666667)
        self.assertAlmostEqual(smart_match.similarity('hello', 'ehllo'), 1)
        self.assertAlmostEqual(smart_match.similarity("Healed", "Sealed"), 0.8333333333333334)
        self.assertAlmostEqual(smart_match.similarity("Healed", "Healthy"), 0.6153846153846154)
        self.assertAlmostEqual(smart_match.similarity("Healed", "Heard"), 0.7272727272727272)
        self.assertAlmostEqual(smart_match.similarity("Healed", "Herded"), 0.6666666666666666)
        self.assertAlmostEqual(smart_match.similarity("Healed", "Help"), 0.6)
        self.assertAlmostEqual(smart_match.similarity("Healed", "Sold"), 0.4)
        self.assertAlmostEqual(smart_match.similarity("Healed", "Help"), 0.6)

        smart_match.set_params(level='term')
        self.assertAlmostEqual(smart_match.similarity('test string1', 'test string1'), 1)
        self.assertAlmostEqual(smart_match.similarity('test string1', 'test string2'), 0.5)
        self.assertAlmostEqual(smart_match.similarity("test", "test string2"), 0.6666666666666667)
        self.assertAlmostEqual(smart_match.similarity("", "test string2"), 0)
        self.assertAlmostEqual(smart_match.similarity("aaa bbb ccc ddd", "aaa bbb ccc eee"), 0.75)
        self.assertAlmostEqual(smart_match.similarity("aaa bbb", "aaa aaa"), 0.5)
        self.assertAlmostEqual(smart_match.similarity("aaa", "aaa aaa"), 0.6666666666666667)
        self.assertAlmostEqual(smart_match.similarity("a b c d", "a b c e"), 0.7500)
        self.assertAlmostEqual(smart_match.similarity("a b c d", "a b e f"), 0.5000)
        self.assertAlmostEqual(smart_match.similarity("a b c", "a b c e f g"), 0.6666666666666667)
        self.assertAlmostEqual(smart_match.similarity("a b b c c", "a b c e f g"), 0.5454545454545454)

        smart_match.set_params(level='char')
        self.assertAlmostEqual(smart_match.similarity(["test", ""], ["test", "string2"]), 0.5)
        self.assertAlmostEqual(smart_match.similarity([], ["test", "string2"]), 0.0)
Example #27
0
    def test_jaro_similarity1(self):

        self.assertAlmostEqual(smart_match.similarity('ABC', 'CBA'),
                               0.5555555555555555)
        self.assertAlmostEqual(smart_match.similarity('CRATE', 'TRACE'),
                               0.7333333333333334)
        self.assertAlmostEqual(smart_match.similarity('CRATE', 'TRACE'),
                               0.7333333333333334)
        self.assertAlmostEqual(
            smart_match.similarity('AABABCAAAC', 'ABAACBAAAC'),
            0.9333333333333332)
        self.assertAlmostEqual(smart_match.similarity('\0\0\0\0', ''),
                               0.0000000000000000)
        self.assertAlmostEqual(smart_match.similarity('He0ll0o', 'Hel00lo'),
                               0.9047619047619048)
        self.assertAlmostEqual(
            smart_match.similarity("He\0ll\0o", "Hel\0\0lo"),
            0.9047619047619048)
        self.assertAlmostEqual(smart_match.similarity('0000', '000000'),
                               0.8888888888888888)
        self.assertAlmostEqual(smart_match.similarity('H0000', '\0000000'),
                               0.8666666666666667)
        self.assertAlmostEqual(
            float("%.4f" % (smart_match.similarity('MARTHA', 'MARHTA'))),
            0.9444)
        self.assertAlmostEqual(
            float("%.4f" % (smart_match.similarity('DWAYNE', 'DUANE'))),
            0.8222)
        self.assertAlmostEqual(
            float("%.4f" % (smart_match.similarity('DIXON', 'DICKSONX'))),
            0.7667)
        self.assertAlmostEqual(
            float("%.4f" % (smart_match.similarity('OZYMANDIAS', 'MARCUS'))),
            0.6000)
        self.assertAlmostEqual(
            float("%.4f" % (smart_match.similarity('OZYMANDIAS', ''))), 0.000)
        self.assertAlmostEqual(
            float("%.4f" %
                  (smart_match.similarity('test string1', 'test string2'))),
            0.9444)
        self.assertAlmostEqual(
            float("%.4f" % (smart_match.similarity("test string1", "Sold"))),
            0.0000)
        self.assertAlmostEqual(
            float("%.4f" % (smart_match.similarity("test", "test string2"))),
            0.7778)
        self.assertAlmostEqual(
            float("%.4f" % (smart_match.similarity("", "test string2"))),
            0.0000)
        self.assertAlmostEqual(
            float("%.4f" % (smart_match.similarity(
                "aaa bbb ccc ddd", "aaa bbb ccc eee"))), 0.8667)
        self.assertAlmostEqual(
            float("%.4f" % (smart_match.similarity('a b c d', 'a b c e'))),
            0.9048)
        self.assertAlmostEqual(
            float("%.4f" % (smart_match.similarity("Healed", "Sealed"))),
            0.8889)
        self.assertAlmostEqual(
            float("%.4f" % (smart_match.similarity('Healed', 'Healthy'))),
            0.7460)
        self.assertAlmostEqual(
            float("%.4f" % (smart_match.similarity('Healed', 'Heard'))),
            0.8222)
        self.assertAlmostEqual(
            float("%.4f" % (smart_match.similarity('Healed', 'Help'))), 0.7500)
        self.assertAlmostEqual(
            float("%.4f" % (smart_match.similarity("test", "test string2"))),
            0.7778)
        self.assertAlmostEqual(
            float("%.4f" % (smart_match.similarity("Healed", "Sold"))), 0.6111)
        self.assertAlmostEqual(
            float("%.4f" % (smart_match.similarity(
                "Sam J Chapman", "Samuel John Chapman"))), 0.7922)
        self.assertAlmostEqual(
            float("%.4f" %
                  (smart_match.similarity("Sam Chapman", "S Chapman"))),
            0.8098)
        self.assertAlmostEqual(
            float(
                "%.4f" %
                (smart_match.similarity("John Smith", "Samuel John Chapman"))),
            0.5945)
        self.assertAlmostEqual(
            float("%.4f" %
                  (smart_match.similarity("John Smith", "Sam Chapman"))),
            0.4131)
        self.assertAlmostEqual(
            float("%.4f" %
                  (smart_match.similarity("John Smith", "Sam J Chapman"))),
            0.4949)
        self.assertAlmostEqual(
            float("%.4f" %
                  (smart_match.similarity("John Smith", "S Chapman"))), 0.4333)
        self.assertAlmostEqual(
            float("%.4f" % (smart_match.similarity(
                "Web Database Applications",
                "Web Database Applications with PHP & MySQL"))), 0.8651)
        self.assertAlmostEqual(
            float("%.4f" % (smart_match.similarity(
                "Web Database Applications",
                "Creating Database Web Applications with PHP and ASP"))),
            0.6901)
        self.assertAlmostEqual(
            float("%.4f" % (smart_match.similarity(
                "Web Database Applications",
                "Building Database Applications on the Web Using PHP3"))),
            0.6353)
        self.assertAlmostEqual(
            float("%.4f" % (smart_match.similarity(
                "Web Database Applications",
                "Building Web Database Applications with Visual Studio 6"))),
            0.6582)
        self.assertAlmostEqual(
            float("%.4f" % (smart_match.similarity(
                "Web Database Applications",
                "Web Application Development With PHP"))), 0.6310)
        self.assertAlmostEqual(
            float("%.4f" % (smart_match.similarity(
                "Web Database Applications",
                "WebRAD: Building Database Applications on the Web with Visual FoxPro and Web Connection"
            ))), 0.6291)
        self.assertAlmostEqual(
            float("%.4f" % (smart_match.similarity(
                "Web Database Applications",
                "Structural Assessment: The Role of Large and Full-Scale Testing"
            ))), 0.4751)
        self.assertAlmostEqual(
            float(
                "%.4f" %
                (smart_match.similarity("Web Database Applications",
                                        "How to Find a Scholarship Online"))),
            0.4882)
        self.assertAlmostEqual(
            float("%.4f" % (smart_match.similarity(
                "Web Aplications",
                "Web Database Applications with PHP & MySQL"))), 0.6635)
        self.assertAlmostEqual(
            float("%.4f" % (smart_match.similarity(
                "Web Aplications",
                "Creating Database Web Applications with PHP and ASP"))),
            0.5980)
        self.assertAlmostEqual(
            float("%.4f" % (smart_match.similarity(
                "Web Aplications",
                "Building Database Applications on the Web Using PHP3"))),
            0.5675)
        self.assertAlmostEqual(
            float("%.4f" % (smart_match.similarity(
                "Web Aplications",
                "Building Web Database Applications with Visual Studio 6"))),
            0.5909)
        self.assertAlmostEqual(
            float("%.4f" % (smart_match.similarity(
                "Web Aplications", "Web Application Development With PHP"))),
            0.7741)
        self.assertAlmostEqual(
            float("%.4f" % (smart_match.similarity(
                "Web Aplications",
                "WebRAD: Building Database Applications on the Web with Visual FoxPro and Web Connection"
            ))), 0.6352)
        self.assertAlmostEqual(
            float("%.4f" % (smart_match.similarity(
                "Web Aplications",
                "Structural Assessment: The Role of Large and Full-Scale Testing"
            ))), 0.4751)
        self.assertAlmostEqual(
            float("%.4f" % (smart_match.similarity(
                "Web Aplications", "How to Find a Scholarship Online"))),
            0.4931)
 def test_similarity(self):
     self.assertEqual(smart_match.similarity('hello', 'hero'), 0.75)
     smart_match.set_params(level='term')
     self.assertAlmostEqual(
         smart_match.similarity('test string1', 'test string2'), 0.5)
Example #29
0
 def test_similarity(self):
     self.assertAlmostEqual(
         smart_match.similarity('Web Aplications',
                                'Web Application Development With PHP'),
         0.8666666666666667)
     self.assertAlmostEqual(smart_match.similarity('', 'eee'), 0)
     self.assertAlmostEqual(smart_match.similarity('aaa', 'eee'), 0)
     self.assertAlmostEqual(smart_match.similarity('eee', 'aaa'), 0)
     self.assertAlmostEqual(smart_match.similarity('ddd', 'aaa'), 0)
     self.assertAlmostEqual(smart_match.similarity('aaa', 'ddd'), 0)
     self.assertAlmostEqual(
         smart_match.similarity('test string1', 'test string2'),
         0.9166666666666666)
     self.assertAlmostEqual(smart_match.similarity('test', 'test string2'),
                            1)
     self.assertAlmostEqual(smart_match.similarity('', 'test string2'), 0)
     self.assertAlmostEqual(
         smart_match.similarity('aaa bbb ccc ddd', 'aaa bbb ccc eee'), 0.8)
     self.assertAlmostEqual(smart_match.similarity('a b c d', 'a b c e'),
                            0.8571428571428571)
     self.assertAlmostEqual(smart_match.similarity('Healed', 'Sealed'),
                            0.8333333333333334)
     self.assertAlmostEqual(smart_match.similarity('Healed', 'Healthy'),
                            0.6666666666666666)
     self.assertAlmostEqual(smart_match.similarity('Healed', 'Heard'), 0.6)
     self.assertAlmostEqual(smart_match.similarity('Healed', 'Hearded'),
                            0.5666666666666667)
     self.assertAlmostEqual(smart_match.similarity('Healed', 'Help'), 0.5)
     self.assertAlmostEqual(smart_match.similarity('Healed', 'Sold'), 0.25)
     self.assertAlmostEqual(
         smart_match.similarity('Sam J Chapman', 'Samuel John Chapman'),
         0.7846153846153846)
     self.assertAlmostEqual(
         smart_match.similarity('Sam Chapman', 'S Chapman'),
         0.8888888888888888)
     self.assertAlmostEqual(
         smart_match.similarity('John Smith', 'Samuel John Chapman'), 0.5)
     self.assertAlmostEqual(
         smart_match.similarity('John Smith', 'Sam Chapman'), 0.1)
     self.assertAlmostEqual(
         smart_match.similarity('John Smith', 'Sam J Chapman'), 0.1)
     self.assertAlmostEqual(
         smart_match.similarity('John Smith', 'S Chapman'),
         0.1111111111111111)
     self.assertAlmostEqual(
         smart_match.similarity(
             'Web Database Applications',
             'Web Database Applications with PHP & MySQL'), 1)
     self.assertAlmostEqual(
         smart_match.similarity(
             'Web Database Applications',
             'Creating Database Web Applications with PHP and ASP'), 0.8160)
     self.assertAlmostEqual(
         smart_match.similarity(
             'Web Database Applications',
             'Building Database Applications on the Web Using PHP3'),
         0.8800)
     self.assertAlmostEqual(
         smart_match.similarity(
             'Web Database Applications',
             'Building Web Database Applications with Visual Studio 6'), 1)
     self.assertAlmostEqual(
         smart_match.similarity('Web Database Applications',
                                'Web Application Development With PHP'),
         0.496)
     self.assertAlmostEqual(
         smart_match.similarity(
             'Web Database Applications',
             'WebRAD: Building Database Applications on the Web with Visual FoxPro and Web Connection'
         ), 0.88)
     self.assertAlmostEqual(
         smart_match.similarity(
             'Web Database Applications',
             'Structural Assessment: The Role of Large and Full-Scale Testing'
         ), 0.096)
     self.assertAlmostEqual(
         smart_match.similarity('Web Database Applications',
                                'How to Find a Scholarship Online'), 0.08)
     self.assertAlmostEqual(
         smart_match.similarity(
             'Web Aplications',
             'Web Database Applications with PHP & MySQL'), 0.76)
     self.assertAlmostEqual(
         smart_match.similarity(
             'Web Aplications',
             'Creating Database Web Applications with PHP and ASP'),
         0.9333333333333333)
     self.assertAlmostEqual(
         smart_match.similarity(
             'Web Aplications',
             'Building Database Applications on the Web Using PHP3'),
         0.7333333333333333)
     self.assertAlmostEqual(
         smart_match.similarity(
             'Web Aplications',
             'Building Web Database Applications with Visual Studio 6'),
         0.76)
     self.assertAlmostEqual(
         smart_match.similarity('Web Aplications',
                                'Web Application Development With PHP'),
         0.8666666666666666)
     self.assertAlmostEqual(
         smart_match.similarity(
             'Web Aplications',
             'WebRAD: Building Database Applications on the Web with Visual FoxPro and Web Connection'
         ), 0.7333333333333333)
     self.assertAlmostEqual(
         smart_match.similarity(
             'Web Aplications',
             'Structural Assessment: The Role of Large and Full-Scale Testing'
         ), 0.1333333333333333)
     self.assertAlmostEqual(
         smart_match.similarity('Web Aplications',
                                'How to Find a Scholarship Online'),
         0.1333333333333333)
Example #30
0
 def test_similarity(self):
     self.assertEqual(
         smart_match.similarity(['Hello', 'world'], ['Hero', 'world']), 0.8)