Пример #1
0
    def test_emptyStrings(self):
        """
        Test emtpy strings using default values
        :return:
        """

        ed = DistanceCalculator()
        self.assertEqual(ed.distance('', ''), 0)
        self.assertEqual(ed.distance('a', ''), 1)
        self.assertEqual(ed.distance('', 'a'), 1)
Пример #2
0
    def test_levensteinDistance(self):

        ed = DistanceCalculator()
        self.assertEqual(ed.distance('book', 'books'), 1)
        self.assertEqual(ed.distance('book', 'back'), 2)
        self.assertEqual(ed.distance('books', 'book'), 1)
Пример #3
0
    def test_nonStandardDistances(self):
        ed = DistanceCalculator(2, 2, 4)

        self.assertEqual(ed.distance('book', 'books'), 2)
        self.assertEqual(ed.distance('book', 'back'), 4)
        self.assertEqual(ed.distance('books', 'book'), 2)
Пример #4
0
    def test_sameStrings(self):
        ed = DistanceCalculator()

        self.assertEqual(ed.distance('abc', 'abc'), 0)