Jump to content

Soundex: Difference between revisions

1,099 bytes added ,  6 years ago
no edit summary
m (added whitespace before the table of contents.)
No edit summary
Line 3,879:
[ok] W452 is the Soundex for Williams
[ok] W422 is the Soundex for Woolcock
</pre>
 
=={{header|Ring}}==
<lang ring>
# Project: Soundex
# Date : 2018/06/11
# Author: Gal Zsolt [~ CalmoSoft ~]
# Email : <calmosoft@gmail.com>
 
name = ["Ashcraf", "Ashcroft", "Gauss", "Ghosh", "Hilbert", "Heilbronn", "Lee", "Lloyd",
"Moses", "Pfister", "Robert", "Rupert", "Rubin","Tymczak", "Soundex", "Example"]
for i = 1 to 16
sp = 10 - len(name[i])
see '"' + name[i] + '"' + copy(" ", sp) + " " + soundex(name[i]) + nl
next
func soundex(name2)
name2 = upper(name2)
n = "01230129022455012623019202"
s = left(name2,1)
p = number(substr(n, ascii(s) - 64, 1))
for i = 2 to len(name2)
n2 = number(substr(n, ascii(name2[i]) - 64, 1))
if n2 > 0 and n2 != 9 and n2 != p s = s + string(n2) ok
if n2 != 9 p = n2 ok
next
return left(s + "000", 4)
</lang>
Output:
<pre>
"Ashcraf" A261
"Ashcroft" A261
"Gauss" G200
"Ghosh" G200
"Hilbert" H416
"Heilbronn" H416
"Lee" L000
"Lloyd" L300
"Moses" M220
"Pfister" P236
"Robert" R163
"Rupert" R163
"Rubin" R150
"Tymczak" T522
"Soundex" S532
"Example" E251
</pre>
 
2,468

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.