This repository was archived by the owner on May 13, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 42
New language_filter gem #13
Copy link
Copy link
Open
Description
Just wanted to give a heads up that I was looking at this and other Ruby profanity filters for work and wasn't finding what I needed, so ended up rolling my own language_filter gem, which works much better for my needs, including:
- The ability to create multiple, independently configured filter instances
- Simpler configuration
- Multiple pre-prackaged matchlists (i.e. blacklists) for language type discrimination (hate, profanity, sex, and violence)
- More robust exceptionlist (i.e. whitelist) handling
- And more in the gem's README...
It doesn't include active model integration yet, so instead of profanity_filter :foo, :bar in your Rails model, you'd currently have to have something like:
before_save :clean_up_language
def clean_up_language
filter = LanguageFilter::Filter.new matchlist: :profanity, replacement: :stars
foo = filter.sanitize(foo)
bar = filter.sanitize(bar)
endSo there's still a lot of room for extensibility that I just haven't had time for or had use for yet, but I think it's a more flexible and robust base to work off for most use cases. Hope others find it useful. :-)
(Oh - and development was a bit rushed, so it wasn't test-driven unfortunately. I'll be writing a test suite soon.)
Metadata
Metadata
Assignees
Labels
No labels