Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Basic Profanity Filter in Objective C for iPhone

How have you like minded individuals tackled the basic challenge of filtering profanity, obviously one can't possibly tackle every scenario but it would be nice to have one at the most basic level as a first line of defense.

In Obj-c I've got

NSString *tokens = [text componentsSeparatedByString:@" "];

And then I loop through each token to see if any of the keywords (I've got about 400 in a list) are found within each token.

Realising False positives are also a problem, if the word is a perfect match, its flagged as profanity otherwise if more than 3 words with profanity are found without being perfect matches it is also flagged as profanity.

Later on I will use a webservice that tackles the problem more precisely, but I really just need something basic. So if you wrote the word penis it would go yup naughty naughty, bad word written.

like image 446
David van Dugteren Avatar asked Nov 14 '25 23:11

David van Dugteren


1 Answers

Obscenity Filters: Bad Idea, or Incredibly Intercoursing Bad Idea?

Jeff has an interesting article to consider before embarking on such a piece of code:

http://www.codinghorror.com/blog/2008/10/obscenity-filters-bad-idea-or-incredibly-intercoursing-bad-idea.html

like image 138
Mark Harrison Avatar answered Nov 17 '25 21:11

Mark Harrison



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!