Profanity Filter
|
|
Hello guys, I am creating an application that allows a user to post messages to a board. I want to be able to filter profanity. For instance if someone types an inappropriate word of 5 characters I want it to read ”#? message_text.hide_profanity! and that would automatically hide all words deemed inappropriate by the filter. I would also be OK with it being part of the validation, i.e. validates_no_profanity :message which would raise errors should there be any profanity in the value. Is there any easy rails plugin or ruby gem that does this. This seems like such a common need for an application that reinventing the wheel seems foolish. Thanks, -Nathan |
|
|
That sounds like an excellent idea. I don’t know of any plugins that do this already – you might try to post a message to the rails-talk list if googling doesn’t turn up anything. Doing it yourself could be pretty easily, actually, depending on how you’re having the users post messages. You could start with a validations callback that checks the message against a known list of words, or words that are stored in a table. Then a simple regex would quickly spot if any of those words appeared in the message. But, if you’re storing the text with Textile or Markdown, you might need to do something a bit different – but hopefully that helps a bit? |
|
|
Nathan I had a similar problem I wanted to solve. I found this REST API that you might want to use. Combined with liberal use of memcached, it can be a speedy, low-footprint solution. If you persisted results in a database, you could eventually build up a sizable word list of your own. |
|
|
Thanks Ed…this is great!! I will likely use this service with this app I’m thinking about working on. I love the Rails community! |
|
|
Hey guys, might be a bit late with the response; but this might help others coming from a search engine. I’ve actually implemented a profanity filter plugin for rails – it’s just a one liner in your model. You can heck it out at: http://github.com/adambair/profanity-filter/tree/master If you encounter any issues, just log your concern at: http://adambair.lighthouseapp.com/projects/12000-profanity-filter/tickets |
|
|
Actually I just renamed this to Fu-fu: The Profanity Filter for Rails. http://github.com/adambair/fu-fu/tree/master http://adambair.lighthouseapp.com/projects/12000-fu-fu/overview |