예제 #1
0
 def _get_distances(self, word):
     distances = set([])
     languages = self.spellchecker.get_languages()
     for lang in languages:
         for w in languages[lang]:
             dist = lev_dist(word, w)
             distances.add((dist, w))
     return [d[1] for d in sorted(distances)]
예제 #2
0
 def test_lev_dist(self):
     self.assertEqual(3, lev_dist("kitten", "sitting"))
     self.assertEqual(3, lev_dist("saturday", "sunday"))
     self.assertEqual(1, lev_dist("can", "pan"))
     self.assertEqual(0, lev_dist("rosebud", "rosebud"))