Basic Profanity Filter in Objective C for iPhone
Posted
by David van Dugteren
on Stack Overflow
See other posts from Stack Overflow
or by David van Dugteren
Published on 2010-05-12T02:23:28Z
Indexed on
2010/05/12
2:34 UTC
Read the original article
Hit count: 309
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.
© Stack Overflow or respective owner