Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
40
Task/Soundex/SenseTalk/soundex.sensetalk
Normal file
40
Task/Soundex/SenseTalk/soundex.sensetalk
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
set names to ["Aschraft","Ashcroft","DiBenedetto","Euler","Gauss","Ghosh","Gutierrez",
|
||||
"Heilbronn","Hilbert","Honeyman","Jackson","Lee","LeGrand","Lissajous","Lloyd",
|
||||
"Moses","Pfister","Robert","Rupert","Rubin","Tymczak","VanDeusen","Van de Graaff","Wheaton"]
|
||||
|
||||
repeat with each name in names
|
||||
put !"[[name]] --> [[name's soundex]]"
|
||||
end repeat
|
||||
|
||||
to handle soundex of aName
|
||||
delete space from aName -- remove spaces
|
||||
put the first character of aName into soundex
|
||||
replace every occurrence of <{letter:char},{:letter}> with "{:letter}" in aName -- collapse double letters
|
||||
delete "H" from aName
|
||||
delete "W" from aName
|
||||
|
||||
set prevCode to 0
|
||||
repeat with each character ch in aName
|
||||
if ch is in ...
|
||||
... "BFPV" then set code to 1
|
||||
... "CGJKQSXZ" then set code to 2
|
||||
... "DT" then set code to 3
|
||||
... "L" then set code to 4
|
||||
... "MN" then set code to 5
|
||||
... "R" then set code to 6
|
||||
... else set code to 0
|
||||
end if
|
||||
if code isn't 0 and the counter > 1 and code isn't prevCode then put code after soundex
|
||||
put code into prevCode
|
||||
end repeat
|
||||
set soundex to the first 4 chars of (soundex & "000") -- fill in with 0's as needed
|
||||
|
||||
set prefix to <("Van" or "Con" or "De" or "Di" or "La" or "Le") followed by a capital letter>
|
||||
if aName begins with prefix then
|
||||
put aName into nameWithoutPrefix
|
||||
delete the first occurrence of prefix in nameWithoutPrefix
|
||||
return [soundex, soundex of nameWithoutPrefix]
|
||||
end if
|
||||
|
||||
return soundex
|
||||
end soundex
|
||||
Loading…
Add table
Add a link
Reference in a new issue