Is there a soundex function for python?

Josh C picture Josh C · Feb 15, 2016 · Viewed 12.3k times · Source

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

Answer

Abdullah Abdelmonem picture Abdullah Abdelmonem · Jan 1, 2017

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'