Example #1
0
 def test_distance(self):
     self.assertEqual(5, levenshtein_distance('kitten', 'sitting'))
     self.assertEqual(1, levenshtein_distance('wii', 'wiki'))
     self.assertEqual(2, levenshtein_distance('comfig', 'config'))
     self.assertEqual(5, levenshtein_distance('update', 'upgrade'))
     self.assertEqual(0, levenshtein_distance('milestone', 'milestone'))
Example #2
0
 def score(cmd, arg):
     if cmd.startswith(arg):
         return 0
     return levenshtein_distance(cmd, arg) / float(len(cmd) + len(arg))
Example #3
0
 def score(cmd, arg):
     if cmd.startswith(arg):
         return 0
     return levenshtein_distance(cmd, arg) / float(len(cmd) + len(arg))
Example #4
0
 def test_distance(self):
     self.assertEqual(5, levenshtein_distance("kitten", "sitting"))
     self.assertEqual(1, levenshtein_distance("wii", "wiki"))
     self.assertEqual(2, levenshtein_distance("comfig", "config"))
     self.assertEqual(5, levenshtein_distance("update", "upgrade"))
     self.assertEqual(0, levenshtein_distance("milestone", "milestone"))
Example #5
0
 def test_distance(self):
     self.assertEqual(5, levenshtein_distance('kitten', 'sitting'))
     self.assertEqual(1, levenshtein_distance('wii', 'wiki'))
     self.assertEqual(2, levenshtein_distance('comfig', 'config'))
     self.assertEqual(5, levenshtein_distance('update', 'upgrade'))
     self.assertEqual(0, levenshtein_distance('milestone', 'milestone'))