Python based unacceptable language filter

Erik Max Francis max at alcyone.com
Mon Oct 3 17:36:29 EDT 2005


Andrew Gwozdziewycz wrote:

> I think he may be referring to "bad" words, and 'filthy' language. At  
> least that's what i got from the question.
> There are many PHP implementations on the web, which could be adapted  
> to python fairly easily. Most of which are probably not the most  
> ideal solution and
> involve alot of stuff like
> 
>        for n in badwords:
>              texttofilter.replace(n, '<bad word deleted>')
> 
> If that's all you need though, maybe it's not so bad.

This is a no-op, since it replaces the text, but then discards it.  You 
meant:

	for badWord in badWords:
	    textToFilter = textToFilter.replace(badWord, '<)!&%(#&)%>')

-- 
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
   If anything is sacred, the human body is sacred.
   -- Walt Whitman



More information about the Python-list mailing list