Skip to content

Instantly share code, notes, and snippets.

@daynebatten
Last active May 25, 2016 19:28
Show Gist options
  • Save daynebatten/63f91004eebda35ef2ed42368fcf317a to your computer and use it in GitHub Desktop.
Save daynebatten/63f91004eebda35ef2ed42368fcf317a to your computer and use it in GitHub Desktop.
-- With metaphone, a hard C and hard K both code to 'K'
-- Note that you specify a maximum encoding length, since metaphone can return long encodings
select
metaphone('kristina', 100), -- KRSTN
metaphone('christina', 100); --KRSTN
-- Metaphone thinks the GH is pronounced like 'laugh'
-- But double metaphone knows the GH is silent
select
metaphone('hayleigh', 100), --HLF
dmetaphone('hayleigh'); --HL
-- Metaphone encodings can get long
select
metaphone('antidisestablishmentarianism', 100); --ANTTSSTBLXMNTRNSM
-- Double metaphone makes sure Smith and Schmidt share at least 1 encoding
select
dmetaphone('smith'), --SM0
dmetaphone_alt('smith'), --XMT
dmetaphone('schmidt'), --XMT
dmetaphone_alt('schmidt'); --SMT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment