Skip to content

Instantly share code, notes, and snippets.

@exhuma
Created January 2, 2013 11:53
Show Gist options
  • Save exhuma/4434056 to your computer and use it in GitHub Desktop.
Save exhuma/4434056 to your computer and use it in GitHub Desktop.
Quick and dirty word filter, slammed together in a minute to answer a question on IRC
"""
quick-and-dirty word filter.
It could sure be made prettier. It's only purpose is to get the brain nudged into the right direction.
"""
BADWORDS = {
u'bad': u'b*d',
u'verybad': u'v*****d',
u'disgusting': u'#*$&^$%'
}
def profilter(text):
return u" ".join(map(lambda word: BADWORDS.get(word.lower(), word),
text.split(' ')))
print profilter('This a bad text. As such it contains VeryBad and DisGuStInG words!')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment