[Distance] Exchange 1 and 0 in the soundex distance, because we try to minimize the distance
authorSimon Chabot <simon.chabot@logilab.fr>
Thu, 18 Oct 2012 15:01:47 +0200
changeset 19 fa22f8965c4a
parent 18 64f8789a2951
child 20 16f66a0aaa0e
[Distance] Exchange 1 and 0 in the soundex distance, because we try to minimize the distance
distances.py
test/test_alignment.py
--- a/distances.py	Thu Oct 18 13:55:25 2012 +0200
+++ b/distances.py	Thu Oct 18 15:01:47 2012 +0200
@@ -97,9 +97,9 @@
 
 def soundex(stra, strb, language = 'french'):
     """ Return the 1/0 distance between the soundex code of stra and strb.
-        1 means they have the same code, 0 they don't
+        0 means they have the same code, 1 they don't
     """
-    return 1 if soundexcode(stra, language) == soundexcode(strb, language) else 0
+    return 0 if soundexcode(stra, language) == soundexcode(strb, language) else 1
 
 def jaccard(stra, strb):
     """ Return the jaccard distance between stra and strb, condering the letters
--- a/test/test_alignment.py	Thu Oct 18 13:55:25 2012 +0200
+++ b/test/test_alignment.py	Thu Oct 18 15:01:47 2012 +0200
@@ -74,8 +74,8 @@
         self.assertEqual(soundexcode('Tymczak', 'english'), 'T522')
         self.assertEqual(soundexcode('Pfister', 'english'), 'P236')
 
-        self.assertEqual(soundex('Rubert', 'Robert', 'english'), 1)
-        self.assertEqual(soundex('Rubin', 'Robert', 'english'), 0)
+        self.assertEqual(soundex('Rubert', 'Robert', 'english'), 0)
+        self.assertEqual(soundex('Rubin', 'Robert', 'english'), 1)
 
     def test_jaccard(self):
         #The jaccard indice between two words is the ratio of the number of