Login

Profanity Function (Disemvowel)

Author:
areich
Posted:
June 28, 2009
Language:
Python
Version:
1.0
Tags:
profanity disemvowel
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. "Magic Link" Management Command by webology 3 weeks, 5 days ago
  2. Closest ORM models to a latitude/longitude point by simonw 3 weeks, 5 days ago
  3. Log the time taken to execute each DB query by kennyx46 3 weeks, 5 days ago
  4. django database snippet by ItsRLuo 1 month ago
  5. Serialize a model instance by chriswedgwood 2 months ago

Comments

Please login first before commenting.