Esempio n. 1
0
class JaroWinklerTest(unittest.TestCase):
    alg = textdistance.JaroWinkler(external=False)

    def test_common(self):
        self.assertAlmostEqual(self.alg.similarity('elephant', 'hippo'), 0.44166666)
        self.assertEqual(self.alg.similarity('fly', 'ant'), 0.0)
        self.assertAlmostEqual(self.alg.similarity('frog', 'fog'), 0.916666666)
        self.assertAlmostEqual(self.alg.similarity('MARTHA', 'MARHTA'), 0.96111111)
        self.assertAlmostEqual(self.alg.similarity('DWAYNE', 'DUANE'), 0.84)
        self.assertAlmostEqual(self.alg.similarity('DIXON', 'DICKSONX'), 0.81333333)
Esempio n. 2
0
class JaroTest(unittest.TestCase):
    alg = textdistance.JaroWinkler(winklerize=False, external=False)

    def test_common(self):
        self.assertAlmostEqual(self.alg.similarity('hello', 'haloa'), 0.73333333)
        self.assertEqual(self.alg.similarity('fly', 'ant'), 0.0)
        self.assertAlmostEqual(self.alg.similarity('frog', 'fog'), 0.91666666)
        self.assertAlmostEqual(self.alg.similarity('ATCG', 'TAGC'), 0.83333333)
        self.assertAlmostEqual(self.alg.similarity('MARTHA', 'MARHTA'), 0.944444444)
        self.assertAlmostEqual(self.alg.similarity('DWAYNE', 'DUANE'), 0.822222222)
        self.assertAlmostEqual(self.alg.similarity('DIXON', 'DICKSONX'), 0.76666666)
Esempio n. 3
0
    def test_common(self):
        self.assertAlmostEqual(self.alg.similarity('elephant', 'hippo'),
                               0.44166666)
        self.assertEqual(self.alg.similarity('fly', 'ant'), 0.0)
        self.assertAlmostEqual(self.alg.similarity('frog', 'fog'), 0.916666666)
        self.assertAlmostEqual(self.alg.similarity('MARTHA', 'MARHTA'),
                               0.96111111)
        self.assertAlmostEqual(self.alg.similarity('DWAYNE', 'DUANE'), 0.84)
        self.assertAlmostEqual(self.alg.similarity('DIXON', 'DICKSONX'),
                               0.81333333)

        # https://github.com/life4/textdistance/issues/39
        ext = textdistance.JaroWinkler(external=True)
        self.assertAlmostEqual(ext.similarity('duck donald', 'duck daisy'),
                               0.867272727272)
Esempio n. 4
0
class JaroTest(unittest.TestCase):
    alg = textdistance.JaroWinkler(winklerize=False, external=False)

    def test_common(self):
        self.assertAlmostEqual(self.alg.similarity('hello', 'haloa'),
                               0.73333333)
        self.assertEqual(self.alg.similarity('fly', 'ant'), 0.0)
        self.assertAlmostEqual(self.alg.similarity('frog', 'fog'), 0.91666666)
        self.assertAlmostEqual(self.alg.similarity('ATCG', 'TAGC'), 0.83333333)
        self.assertAlmostEqual(self.alg.similarity('MARTHA', 'MARHTA'),
                               0.944444444)
        self.assertAlmostEqual(self.alg.similarity('DWAYNE', 'DUANE'),
                               0.822222222)
        self.assertAlmostEqual(self.alg.similarity('DIXON', 'DICKSONX'),
                               0.76666666)

        # https://github.com/life4/textdistance/issues/41
        self.assertAlmostEqual(
            self.alg.similarity('Sint-Pietersplein 6, 9000 Gent',
                                'Test 10, 1010 Brussel'),
            0.5182539682539683,
        )