def test_distanceOfWordWithDifferentLengthAndChars(self): self.assertEqual(2, edit_distance('ab', 'max')) self.assertEqual(6, edit_distance('aberwas', 'dasaber')) self.assertEqual( 24, edit_distance('kohlensäurehaltigesmineralwasser', 'hackfleischhassenderzerhacker'))
def speed_test(word_1: str, word_2: str): edit_distance(word_1, word_2) damerau_levenshtein_distance(word_1, word_2) return ngram_movers_distance(word_1, word_2)
def test_finds_edit_distance_0(): string1 = 'cat' assert_that(edit_distance(string1, string1), equal_to(0))
def test_finds_edit_distance_3(): string1 = 'cat' string2 = 'ale' assert_that(edit_distance(string1, string2), equal_to(3))
def test_finds_edit_distance_1(): string1 = 'cat' string2 = 'cats' assert_that(edit_distance(string1, string2), equal_to(1))
def test_distanceOfSameWordIsZero(self): word = 'whatwg' self.assertEqual(0, edit_distance(word, word))
def test_distanceOfTwoEmptyWordsIsZero(self): self.assertEqual(0, edit_distance('', ''))
def test_argumentOrderDoesNotChangeTheDistance(self): word_a = 'hallo' word_b = 'halloo' self.assertEqual(edit_distance(word_a, word_b), edit_distance(word_b, word_a))
def test_distanceForAdditionalLetterIsOne(self): self.assertEqual(1, edit_distance('hallo', 'halloo'))
def test_distanceOfSameLengthWordsIsAmountOfDifferentChars(self): self.assertEqual(1, edit_distance('hallo', 'hOllo')) self.assertEqual(2, edit_distance('HAllo', 'hallo'))
def test_distanceOfDifferentCharsIsOne(self): self.assertEqual(1, edit_distance('a', 'b'))
def test_distanceToEmptyWordIsWordLength(self): word = 'whatwg' self.assertEqual(len(word), edit_distance(word, ''))