A better way of dealing w/profanity - disemvowel it!
From Wikipedia, "disemvoweling is a technique used to censor unwanted postings such as spam, internet trolling, rudeness or criticism and yet maintain some transparency, both of the act and the underlying word." Credit: Boing Boing
Example:
This original sentence: In the fields of Internet discussion and forum moderation, disemvoweling (also spelled disemvowelling) is the removal of vowels from text. would be disemvowelled to look like this: n th flds f ntrnt dscssn nd frm mdrtn, dsmvwlng (ls splld dsmvwllng) s th rmvl f vwls frm txt.
Usage:
body_input = form.cleaned_data["body"]
body_input = disemvowel_profanity(body_input)
1 2 3 4 5 6 7 8 | from django.conf import settings
import re
def disemvowel_profanity(value):
for w in settings.PROFANITIES_LIST:
if value.find(w)!=-1:
value = value.replace(value, re.sub(r'[AEIOUYaeiouy]', '', value))
return value
|
More like this
- Template tag - list punctuation for a list of items by shapiromatron 11 months, 2 weeks ago
- JSONRequestMiddleware adds a .json() method to your HttpRequests by cdcarter 11 months, 3 weeks ago
- Serializer factory with Django Rest Framework by julio 1 year, 6 months ago
- Image compression before saving the new model / work with JPG, PNG by Schleidens 1 year, 7 months ago
- Help text hyperlinks by sa2812 1 year, 7 months ago
Comments
Please login first before commenting.