Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a soundex function for python?

Is there a soundex function for python and if not how would you go about making a soundex code?

Soundex
Code    Letters 
1   B, F, P, V  
2   C, G, J, K, Q, S, X, Z  
3   D, T    
4   L   
5   M, N    
6   R   
SKIP   A, E, H, I, O, U, W, Y, H, W, and Y

For example:

Jackson = J250

Washington = W252

Clement = C455

Ashcraft = A261

Wu = W000

like image 210
Josh C Avatar asked Dec 25 '22 09:12

Josh C


2 Answers

Yes , you can use Fuzzy which is a python library implementing some phonetic algorithms.

sudo pip install fuzzy

>>> import fuzzy
>>> soundex = fuzzy.Soundex(4)
>>> soundex("Jackson")
'J250'
>>> soundex("Washington")
'W252'
>>> soundex("Clement")
'C453'
>>> soundex("Ashcraft")
'A261'
>>> soundex("Wu")
'W000'
like image 197
Abdullah Abdelmonem Avatar answered Jan 08 '23 04:01

Abdullah Abdelmonem


You can use jellyfish

sudo pip install jellyfish

print "Soundex\t\t=", jellyfish.soundex("Ala ma kaca")
>Soundex                = A452
#...
>Metaphone              = AL M KK
>NYSIIS                 = AL
>Match rating codex     = ALMKC
like image 21
ravyr Avatar answered Jan 08 '23 06:01

ravyr