File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 1+ ##SOUNDEX ALGORITHM
2+
3+ text = 'AMANMADHUKAR' ##Enter your text here
4+ plain = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' ## This is the plain text
5+ code = '01230120022455012623010202' ## Here I have assigned the code value respective to the alphabet
6+ l = [] ## Create empty list
7+ l .append (text [0 ]) ## So first character goes as it is (here it will be A)
8+ for i in range (1 ,len (text )): ## Traversing from 1st Index i.e. M to R over here that is the last character
9+ if (code [plain .index (text [i - 1 ])]!= code [plain .index (text [i ])]): ## Removing Zeroes from the list
10+ if (code [plain .index (text [i ])] != '0' ): ## If not zero
11+ l .append (code [plain .index (text [i ])]) ## then append into list
12+ for i in range (4 ): ## Soundex considers only Four characters therefore traversing only four times
13+ if (len (l )< 4 ): ## Suppose the Character less than four then we append 0 in last
14+ l .append ('0' )
15+
16+
17+ print (l ) ##printing list
18+ print ('' .join (l [:4 ])) ##lastly merging the list
19+
20+
21+ ## Happy Coding :)
You can’t perform that action at this time.
0 commit comments