Beispiel #1
0
 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'))
Beispiel #2
0
 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)
Beispiel #3
0
def test_finds_edit_distance_0():
    string1 = 'cat'
    assert_that(edit_distance(string1, string1), equal_to(0))
Beispiel #4
0
def test_finds_edit_distance_3():
    string1 = 'cat'
    string2 = 'ale'
    assert_that(edit_distance(string1, string2), equal_to(3))
Beispiel #5
0
def test_finds_edit_distance_1():
    string1 = 'cat'
    string2 = 'cats'
    assert_that(edit_distance(string1, string2), equal_to(1))
Beispiel #6
0
 def test_distanceOfSameWordIsZero(self):
     word = 'whatwg'
     self.assertEqual(0, edit_distance(word, word))
Beispiel #7
0
 def test_distanceOfTwoEmptyWordsIsZero(self):
     self.assertEqual(0, edit_distance('', ''))
Beispiel #8
0
 def test_argumentOrderDoesNotChangeTheDistance(self):
     word_a = 'hallo'
     word_b = 'halloo'
     self.assertEqual(edit_distance(word_a, word_b),
                      edit_distance(word_b, word_a))
Beispiel #9
0
 def test_distanceForAdditionalLetterIsOne(self):
     self.assertEqual(1, edit_distance('hallo', 'halloo'))
Beispiel #10
0
 def test_distanceOfSameLengthWordsIsAmountOfDifferentChars(self):
     self.assertEqual(1, edit_distance('hallo', 'hOllo'))
     self.assertEqual(2, edit_distance('HAllo', 'hallo'))
Beispiel #11
0
 def test_distanceOfDifferentCharsIsOne(self):
     self.assertEqual(1, edit_distance('a', 'b'))
Beispiel #12
0
 def test_distanceToEmptyWordIsWordLength(self):
     word = 'whatwg'
     self.assertEqual(len(word), edit_distance(word, ''))