Login

Profanity Function (Disemvowel)

Author:
areich
Posted:
June 28, 2009
Language:
Python
Version:
1.0
Score:
0 (after 6 ratings)

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

  1. Template tag - list punctuation for a list of items by shapiromatron 2 months, 2 weeks ago
  2. JSONRequestMiddleware adds a .json() method to your HttpRequests by cdcarter 2 months, 3 weeks ago
  3. Serializer factory with Django Rest Framework by julio 9 months, 2 weeks ago
  4. Image compression before saving the new model / work with JPG, PNG by Schleidens 10 months, 1 week ago
  5. Help text hyperlinks by sa2812 11 months ago

Comments

Please login first before commenting.