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. Month / Year SelectDateWidget based on django SelectDateWidget by pierreben 2 weeks, 4 days ago
  2. Python Django CRUD Example Tutorial by tuts_station 1 month ago
  3. Browser-native date input field by kytta 2 months, 2 weeks ago
  4. Generate and render HTML Table by LLyaudet 2 months, 3 weeks ago
  5. My firs Snippets by GutemaG 3 months ago

Comments

Please login first before commenting.