Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New language_filter gem #13

Open
chrisvfritz opened this issue Jul 4, 2013 · 0 comments
Open

New language_filter gem #13

chrisvfritz opened this issue Jul 4, 2013 · 0 comments

Comments

@chrisvfritz
Copy link

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)
end

So 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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant