Beispiel #1
0
 def test_levenshtein_similarity(self):
     # Returns 1.0 (identical strings).
     v = metrics.levenshtein_similarity("gallahad", "gallahad")
     self.assertEqual(v, 1.0)
     # Returns 0.75 (2 out of 8 characters differ).
     v = metrics.levenshtein_similarity("gallahad", "g_ll_had")
     self.assertEqual(v, 0.75)
Beispiel #2
0
 def test_levenshtein_similarity(self):
     # Assert 1.0 (identical strings).
     v = metrics.levenshtein_similarity("gallahad", "gallahad")
     self.assertEqual(v, 1.0)
     # Assert 0.75 (2 out of 8 characters differ).
     v = metrics.levenshtein_similarity("gallahad", "g_ll_had")
     self.assertEqual(v, 0.75)
     print("pattern.metrics.levenshtein_similarity()")
Beispiel #3
0
 def test_similarity(self):
     self.assertEqual(
         metrics.levenshtein_similarity("night", "nacht"), 
         metrics.similarity("night", "nacht", metrics.LEVENSHTEIN))
     self.assertEqual(
         metrics.dice_coefficient("night", "nacht"), 
         metrics.similarity("night", "nacht", metrics.DICE))