Exemplo n.º 1
0
    def test_ameixa_alerta(self):
        string1= "ameixa"
        string2 = "alerta"

        self.assertEquals(3, edit_distance(string1, string2))

        mins = min(edit_distance("meixa", "lerta"), edit_distance("ameix", "alert"),
                              1 + edit_distance("meixa","alerta"), 1 + edit_distance("ameix", "alerta"),
                              1 + edit_distance("ameixa", "lerta"), 1 + edit_distance("ameix", "alerta"))
        self.assertEquals(3, mins)
Exemplo n.º 2
0
    def test_two_non_empty_strings_different_length(self):
        string1 = "sort"
        string2 = "sport"

        self.assertEquals(1, edit_distance(string1, string2))
        self.assertEquals(1, edit_distance(string2, string1))
Exemplo n.º 3
0
    def test_one_empty_string(self):
        string1 = ""
        string2 = "abc"

        self.assertEquals(len(string2), edit_distance(string1, string2))
        self.assertEquals(len(string2), edit_distance(string2, string1))
Exemplo n.º 4
0
    def test_two_non_empty_strings_same_length(self):
        string1 = "ameixa"
        string2 = "alerta"

        self.assertEquals(3, edit_distance(string1, string2))
        self.assertEquals(3, edit_distance(string2, string1))
Exemplo n.º 5
0
    def test_empty_strings(self):
        string1 = ""
        string2 = ""

        self.assertEquals(0, edit_distance(string1, string2))
        self.assertEquals(0, edit_distance(string2, string1))