Created
January 2, 2013 11:53
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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