[distance] move soundex to soundexcode (related #128982)
authorSimon Chabot <simon.chabot@logilab.fr>
Wed, 17 Oct 2012 12:04:41 +0200
changeset 10 9d29f8f854e9
parent 9 18faa981dea6
child 11 c4d63951cc16
[distance] move soundex to soundexcode (related #128982) In fact, soundexcode is the function returning the soundex code of a word, and soundex will be the 1/0 distance between two words. (1 meaning both have the same code, 0 otherwise)
distances.py
test/test_alignment.py
--- a/distances.py	Wed Oct 17 11:56:22 2012 +0200
+++ b/distances.py	Wed Oct 17 12:04:41 2012 +0200
@@ -23,7 +23,7 @@
             thisrow[y] = min(delcost, addcost, subcost)
     return thisrow[lenb - 1]
 
-def soundex(word, language = 'french'):
+def soundexcode(word, language = 'french'):
     """ Return the Soundex code of the word ``word``
         For more information about soundex code see wiki_
 
--- a/test/test_alignment.py	Wed Oct 17 11:56:22 2012 +0200
+++ b/test/test_alignment.py	Wed Oct 17 12:04:41 2012 +0200
@@ -38,7 +38,7 @@
 """
 
 from cubicweb.devtools import testlib
-from cubes.alignment.distances import (levenshtein, soundex)
+from cubes.alignment.distances import (levenshtein, soundex, soundexcode)
 
 class DistancesTest(testlib.CubicWebTC):
     def test_levenshtein(self):
@@ -63,12 +63,12 @@
         #"Pfister" yields "P236" not "P123" (the first two letters have the same
         #number and are coded once as 'P').
 
-        self.assertEqual(soundex('Robert', 'english'), 'R163')
-        self.assertEqual(soundex('Rubert', 'english'), 'R163')
-        self.assertEqual(soundex('Rubin', 'english'), 'R150')
-        self.assertEqual(soundex('Ashcraft', 'english'), 'A261')
-        self.assertEqual(soundex('Tymczak', 'english'), 'T522')
-        self.assertEqual(soundex('Pfister', 'english'), 'P236')
+        self.assertEqual(soundexcode('Robert', 'english'), 'R163')
+        self.assertEqual(soundexcode('Rubert', 'english'), 'R163')
+        self.assertEqual(soundexcode('Rubin', 'english'), 'R150')
+        self.assertEqual(soundexcode('Ashcraft', 'english'), 'A261')
+        self.assertEqual(soundexcode('Tymczak', 'english'), 'T522')
+        self.assertEqual(soundexcode('Pfister', 'english'), 'P236')
 
 
 if __name__ == '__main__':