问题
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
回答1:
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
回答2:
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'
来源:https://stackoverflow.com/questions/35403335/is-there-a-soundex-function-for-python