Basic profanity filter library for iOS and Mac OS X apps
Objective-C
Latest commit f671053 Sep 17, 2013 @MigrantP MigrantP Merge pull request #2 from whuu/master
Polish list added
Permalink
Failed to load latest commit information.
IODProfanityFilter Polish list added Sep 7, 2013
Samples/ProfanityFilterSample Polish list added Sep 7, 2013
.gitignore Initial commit Feb 28, 2013
LICENSE Add license Feb 28, 2013
README.md Update readme with Polish list Sep 7, 2013

README.md

IODProfanityFilter

IODProfanityFilter provides a basic profanity filter for iOS and Mac OS X apps. It has the following goals:

  • Simplicity of use
  • Performance
  • Minimizing false positives

It is not intended to be the "be-all end-all" profanity filter; just something basic that doesn't have to worry about dealing with the Scunthorpe Problem. I created this library because I needed a simple filter for an app that has user-generated content and is used by a lot of kids. Nothing turned up for iOS, so here it is!

IODProfanityFilter only matches whole words and does not attempt to check for l33t-speak or anything like that.

The filter works on the user's locale and supports the following languages so far: German, English, Spanish, French, Italian, Japanese, Dutch, Polish, Portuguese, Russian, and Chinese.

Installation:

The best way to include it in your project is with CocoaPods. If you're not using CocoaPods, you should probably start using CocoaPods.

Usage:

To filter a string, use either the provided NSString category methods or the methods on IODProfanityFilter, whichever you prefer.

NSString *filtered = [@"a great fucking example string" iod_filteredString]; // @"a great ∗∗∗∗∗∗∗ example string"

or

NSString *filtered = [IODProfanityFilter stringByFilteringString:@"a great fucking example string"]; // @"a great ∗∗∗∗∗∗∗ example string"

You can have greater control over the output by using stringByFilteringString:withReplacementString: or by using rangesOfFilteredWordsInString:. The latter will give you the ranges so you can do whatever you want; perhaps give the user bonus points for using dirty words!

Acknowledgements:

The lovely word lists were initially created by Shutterstock.