The Double Metaphone search algorithm as described in [0], using the Python metaphone library
In [1]:
from metaphone import doublemetaphone
badwords = open('names.csv', 'r').read().split(',')
dmp_badwords = [(doublemetaphone(word), word) for word in badwords]
In [1]:
def soundslike(text):
phonetic = doublemetaphone(text)
if phonetic[1] == '':
phonetic = [phonetic[0]]
print phonetic
for p in phonetic:
for word in dmp_badwords:
if p in word[0]:
print text, "sounds kinda like", word[1]
print word[0]
In [ ]: