Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
10
Task/Soundex/Python/soundex-1.py
Normal file
10
Task/Soundex/Python/soundex-1.py
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
from itertools import groupby
|
||||
|
||||
def soundex(word):
|
||||
codes = ("bfpv","cgjkqsxz", "dt", "l", "mn", "r")
|
||||
soundDict = dict((ch, str(ix+1)) for ix,cod in enumerate(codes) for ch in cod)
|
||||
cmap2 = lambda kar: soundDict.get(kar, '9')
|
||||
sdx = ''.join(cmap2(kar) for kar in word.lower())
|
||||
sdx2 = word[0].upper() + ''.join(k for k,g in list(groupby(sdx))[1:] if k!='9')
|
||||
sdx3 = sdx2[0:4].ljust(4,'0')
|
||||
return sdx3
|
||||
8
Task/Soundex/Python/soundex-2.py
Normal file
8
Task/Soundex/Python/soundex-2.py
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
>>>print soundex("soundex")
|
||||
S532
|
||||
>>>print soundex("example")
|
||||
E251
|
||||
>>>print soundex("ciondecks")
|
||||
C532
|
||||
>>>print soundex("ekzampul")
|
||||
E251
|
||||
Loading…
Add table
Add a link
Reference in a new issue