Coder Social home page Coder Social logo

gbenedict / fu-fu Goto Github PK

View Code? Open in Web Editor NEW

This project forked from adambair/fu-fu

1.0 2.0 1.0 682 KB

Fu-fu: The Profanity Filter for Rails.

Home Page: http://adambair.lighthouseapp.com/projects/12000-fu-fu/overview

License: MIT License

Ruby 100.00%

fu-fu's Introduction

Fu-fu: The Profanity Filter for Rails

This plugin will allow you to filter profanity using basic replacement or a dictionary term.

History

Disclaimer

This plugin is provided as is - therefore, the creators and contributors of this plugin are not responsible for any damages that may result from it’s usage. Use at your own risk; backup your data.

Example

You can use it in your models:

Notice – there are two profanity filters, one is destructive. Beware the exclamation point (profanity_filter!).

Non-Destructive (filters content when called, original text remains in the database)

profanity_filter :foo, :bar
  # banned words will be replaced with @#$%
profanity_filter :foo, :bar, :method => 'dictionary'
  # banned words will have their vowels replaced

The non-destructive profanity_filter provides different versions of the filtered attribute:
  some_model.foo => 'filtered version'
  some_model.foo_original => 'non-filtered version'

Destructive (saves the filtered content to the database)

profanity_filter! :foo, :bar
  # banned words will be replaced with @#$%
profanity_filter! :foo, :bar, :method => 'dictionary'
  # banned words will have their vowels replaced

You can also use the filter directly:

ProfanityFilter::Base.clean(text)
ProfanityFilter::Base.clean(text, 'dictionary')

Benchmarks

Inquiring minds can checkout the simple benchmarks I’ve included so you can have an idea of what kind of performance to expect. I’ve included some quick scenarios including strings of (100, 1000, 5000, 1000) words and dictionaries of (100, 1000, 5000, 25000, 50000, 100000) words.

You can run the benchmarks via:

ruby test/benchmark/fu-fu_benchmark.rb

TODO

  • This plugin is not currently filtering words that are punctuation delimited (ex. ‘f-u-c-k’).

  • Turn this into a gem (and move over to rspec)

  • May break ProfanityFilter out on it’s own

  • Clean up dictionary implementation and subsitution (suboptimal and messy)

  • Move benchmarks into a rake task

License

Fu-fu: The Profanity Filter for Rails uses the MIT License. Please see the MIT-LICENSE file.

Resources

Created by Adam Bair ([email protected]) of Intridea (www.intridea.com) in the open source room at RailsConf 2008.

fu-fu's People

Contributors

adambair avatar gbenedict avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.