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)
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)
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)
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)
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)
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)
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.4285714285714285)
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
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)
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)
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( smart_match.similarity('test string1', 'test string2'), 0.3333333333333333)
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)
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)
def test_similarity(self): self.assertEqual(smart_match.similarity('hello', 'hero'), 0.75) self.assertAlmostEqual(smart_match.similarity('abcd', 'abce'), 0.75) self.assertAlmostEqual(smart_match.similarity('abcd', 'abef'), 0.5) self.assertAlmostEqual(smart_match.similarity('abc', 'abcefg'), 1) self.assertAlmostEqual(smart_match.similarity('abbcc', 'abcefg'), 0.6) 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.8) self.assertAlmostEqual(smart_match.similarity('Healed', 'Herded'), 0.6666666666666666) self.assertAlmostEqual(smart_match.similarity('Healed', 'Help'), 0.75) self.assertAlmostEqual(smart_match.similarity('Healed', 'Sold'), 0.5) 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'), 1) 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 ccc ddd 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'), 1) self.assertAlmostEqual(smart_match.similarity('a b b c c', 'a b c e f g'), 0.6) 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.5) 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'), 1) self.assertAlmostEqual(smart_match.similarity('Web Database Applications', 'Creating Database Web Applications with PHP and ASP'), 1) self.assertAlmostEqual(smart_match.similarity('Web Database Applications', 'Building Database Applications on the Web Using PHP3'), 1) 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.3333333333333333) self.assertAlmostEqual(smart_match.similarity('Web Database Applications', 'WebRAD: Building Database Applications on the Web with Visual FoxPro and Web Connection'), 1) 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.5) 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.5) self.assertAlmostEqual(smart_match.similarity('Web Aplications', 'Building Web Database Applications with Visual Studio 6'), 0.5) self.assertAlmostEqual(smart_match.similarity('Web Aplications', 'Web Application Development With PHP'), 0.5) self.assertAlmostEqual(smart_match.similarity('Web Aplications', 'WebRAD: Building Database Applications on the Web with Visual FoxPro and Web Connection'), 0.5) 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) smart_match.set_params(level='char') self.assertAlmostEqual(smart_match.similarity(("test", None), ("test","string2")), 0.5)
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)
def test_score(self): self.assertEqual(smart_match.score('test string1', 'test string2'), -1) smart_match.set_params(gap=-1, mismatch=-1, match=1) self.assertEqual(smart_match.score('GATTACA', 'GCATGCU'), 0) self.assertAlmostEqual(smart_match.score('Healed', 'Help'), 0) smart_match.set_params(gap=-1, mismatch=-1, match=1) self.assertAlmostEqual( smart_match.score('Sam J Chapman', 'Samuel John Chapman'), 7) self.assertAlmostEqual(smart_match.score('Sam Chapman', 'S Chapman'), 7) self.assertAlmostEqual( smart_match.score('John Smith', 'Samuel John Chapman'), -8) self.assertAlmostEqual(smart_match.score('John Smith', 'Sam Chapman'), -9) self.assertAlmostEqual( smart_match.score('John Smith', 'Sam J Chapman'), -9) self.assertAlmostEqual(smart_match.score('John Smith', 'S Chapman'), -7) self.assertAlmostEqual( smart_match.score('Web Database Applications', 'Web Database Applications with PHP & MySQL'), 8) self.assertAlmostEqual( smart_match.score( 'Web Database Applications', 'Building Web Database Applications with Visual Studio 6'), -5) self.assertAlmostEqual( smart_match.score('Web Database Applications', 'Web Application Development With PHP'), -15) self.assertAlmostEqual( smart_match.score( 'Web Database Applications', 'WebRAD: Building Database Applications on the' ' Web with Visual FoxPro and Web Connection'), -37) self.assertAlmostEqual( smart_match.score( 'Web Database Applications', 'Structural Assessment: The Role of Large and' ' Full-Scale Testing'), -42) self.assertAlmostEqual( smart_match.score('Web Database Applications', 'How to Find a Scholarship Online'), -21) self.assertAlmostEqual( smart_match.score('Web Aplications', 'Web Database Applications with PHP & MySQL'), -12)
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): 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_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)
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_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)
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)
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)
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)
def test_similarity(self): smart_match.set_params(level='term') self.assertAlmostEqual( smart_match.similarity('test string1', 'test string2'), 0.5)
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.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)
def test_similarity(self): self.assertAlmostEqual( smart_match.similarity('test string1', 'test string2'), 0.9583333333333334) smart_match.set_params(gap=-1, mismatch=-1, match=1) self.assertAlmostEqual(smart_match.similarity('GATTACA', 'GCATGCU'), 0.5) smart_match.set_params(gap=-1, mismatch=-1, match=1) self.assertAlmostEqual(smart_match.similarity('a b c d', 'a b c e'), 0.8571428571428571) smart_match.set_params(gap=-1, mismatch=-1, match=1) self.assertAlmostEqual(smart_match.similarity('Healed', 'Sealed'), 0.8333333333333334) smart_match.set_params(gap=-1, mismatch=-1, match=1) self.assertAlmostEqual(smart_match.similarity('Healed', 'Healthy'), 0.5714285714285714) smart_match.set_params(gap=-1, mismatch=-1, match=1) self.assertAlmostEqual(smart_match.similarity('Healed', 'Help'), 0.5) smart_match.set_params(gap=-1, mismatch=-1, match=1) self.assertAlmostEqual(smart_match.similarity('Healed', 'Sold'), 0.3333333333333333) smart_match.set_params(gap=-1, mismatch=-1, match=1) self.assertAlmostEqual(smart_match.similarity('Healed', 'Help'), 0.5) self.assertAlmostEqual( smart_match.similarity('Sam J Chapman', 'Samuel John Chapman'), 0.6842105263157895) self.assertAlmostEqual( smart_match.similarity('Sam Chapman', 'S Chapman'), 0.8181818181818182) self.assertAlmostEqual( smart_match.similarity('John Smith', 'Samuel John Chapman'), 0.2894736842105263) self.assertAlmostEqual( smart_match.similarity('John Smith', 'Sam Chapman'), 0.09090909090909091) self.assertAlmostEqual( smart_match.similarity('John Smith', 'Sam J Chapman'), 0.15384615384615385) self.assertAlmostEqual( smart_match.similarity('John Smith', 'S Chapman'), 0.15) self.assertAlmostEqual( smart_match.similarity( 'Web Database Applications', 'Web Database Applications with PHP & MySQL'), 0.5952380952380952) self.assertAlmostEqual( smart_match.similarity( 'Web Database Applications', 'Creating Database Web Applications with PHP and ASP'), 0.45098039215686275) self.assertAlmostEqual( smart_match.similarity( 'Web Database Applications', 'Building Database Applications on the Web Using PHP3'), 0.4230769230769231) self.assertAlmostEqual( smart_match.similarity( 'Web Database Applications', 'Building Web Database Applications with Visual Studio 6'), 0.45454545454545453) self.assertAlmostEqual( smart_match.similarity('Web Database Applications', 'Web Application Development With PHP'), 0.2916666666666667) self.assertAlmostEqual( smart_match.similarity( 'Web Database Applications', 'WebRAD: Building Database Applications on the' ' Web with Visual FoxPro and Web Connection'), 0.28735632183908044) self.assertAlmostEqual( smart_match.similarity( 'Web Database Applications', 'Structural Assessment: The Role of Large and Full-Scale Testing' ), 0.16666666666666666) self.assertAlmostEqual( smart_match.similarity('Web Database Applications', 'How to Find a Scholarship Online'), 0.171875) self.assertAlmostEqual( smart_match.similarity( 'Web Aplications', 'Web Database Applications with PHP & MySQL'), 0.35714285714285715)
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)
def test_similarity(self): self.assertAlmostEqual( float('%.4f' % smart_match.similarity("test string1", "test string2")), 0.9167) self.assertAlmostEqual( float('%.4f' % smart_match.similarity("test", "test string2")), 1.0000) 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.8000) self.assertAlmostEqual( float('%.4f' % smart_match.similarity("a b c d", "a b c e")), 0.8571) self.assertAlmostEqual( float('%.4f' % smart_match.similarity("Healed", "Sealed")), 0.8333) self.assertAlmostEqual( float('%.4f' % smart_match.similarity("Healed", "Healthy")), 0.6667) self.assertAlmostEqual( float('%.4f' % smart_match.similarity("Healed", "Heard")), 0.6000) self.assertAlmostEqual( float('%.4f' % smart_match.similarity("Healed", "Herded")), 0.3333) self.assertAlmostEqual( float('%.4f' % smart_match.similarity( "Sam J Chapman", "Samuel John Chapman")), 0.7692) self.assertAlmostEqual( float('%.4f' % smart_match.similarity("Sam Chapman", "S Chapman")), 0.8889) self.assertAlmostEqual( float('%.4f' % smart_match.similarity("John Smith", "Samuel John Chapman")), 0.5000) self.assertAlmostEqual( float( '%.4f' % smart_match.similarity("aaa bbb ccc ddd", "aaa bbb ccc eee")), 0.8000) self.assertAlmostEqual( float('%.4f' % smart_match.similarity("John Smith", "Sam Chapman")), 0.1500) self.assertAlmostEqual( float('%.4f' % smart_match.similarity("John Smith", "S Chapman")), 0.1111) self.assertAlmostEqual( float('%.4f' % smart_match.similarity( "Web Database Applications", "Web Database Applications with PHP & MySQL")), 1.0000) self.assertAlmostEqual( float('%.4f' % smart_match.similarity( "Web Database Applications", "Building Web Database Applications with Visual Studio 6")), 1.0000) self.assertAlmostEqual( float('%.4f' % smart_match.similarity( "Web Database Applications", "Web Application Development With PHP")), 0.5000) self.assertAlmostEqual( float('%.4f' % smart_match.similarity( "Web Database Applications", "WebRAD: Building Database Applications on the Web with Visual FoxPro and Web Connection" )), 0.8800) self.assertAlmostEqual( float('%.4f' % smart_match.similarity( "Web Database Applications", "Structural Assessment: The Role of Large and Full-Scale Testing" )), 0.1000) self.assertAlmostEqual( float('%.4f' % smart_match.similarity("Web Database Applications", "How to Find a Scholarship Online")), 0.0800) self.assertAlmostEqual( float('%.4f' % smart_match.similarity( "Web Aplications", "Web Database Applications with PHP & MySQL")), 0.8000) self.assertAlmostEqual( float('%.4f' % smart_match.similarity( "Web Aplications", "Creating Database Web Applications with PHP and ASP")), 0.9667) self.assertAlmostEqual( float('%.4f' % smart_match.similarity( "Web Aplications", "Web Application Development With PHP")), 0.9000) self.assertAlmostEqual( float('%.4f' % smart_match.similarity( "Web Aplications", "Structural Assessment: The Role of Large and Full-Scale Testing" )), 0.1667) self.assertAlmostEqual( float('%.4f' % smart_match.similarity( "Web Aplications", "How to Find a Scholarship Online")), 0.1333) self.assertAlmostEqual( float('%.4f' % smart_match.similarity('GGTTGACTA', 'TGTTACGG')), 0.5625) smart_match.set_params(gap=-2, match=3, mismatch=-3) self.assertAlmostEqual( float('%.4f' % smart_match.similarity('GGTTGACTA', 'TGTTACGG')), 0.5417)