github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

adambair / fu-fu

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 59
    • 8
  • Source
  • Commits
  • Network (8)
  • Issues (1)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

Fu-fu: The Profanity Filter for Rails. — Read more

  cancel

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

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Update TODO list and README formatting 
adambair (author)
Wed Jan 20 19:16:51 -0800 2010
commit  5651f5958ad96386288f1c755f46303c88709679
tree    bd926ea8fa86784c739b1a7e503ee1edf6529e4f
parent  b3e0510aa51c649b1527b37676b8efc100e08a47
fu-fu /
name age
history
message
file .gitignore Sun Jun 01 01:45:16 -0700 2008 Adding the rakefile back in and setting an ignore [adambair]
file MIT-LICENSE Thu Jun 05 12:29:50 -0700 2008 Adding MIT license file - thanks Simon [adambair]
file README.rdoc Wed Jan 20 19:16:51 -0800 2010 Update TODO list and README formatting [adambair]
file Rakefile Sun Jun 01 01:45:16 -0700 2008 Adding the rakefile back in and setting an ignore [adambair]
directory config/ Tue Aug 04 20:25:04 -0700 2009 Will now filter punctionation delimited profani... [neilang]
file init.rb Sun Jun 01 01:30:14 -0700 2008 Initial import of the original plugin [adambair]
directory lib/ Wed Jan 20 19:05:04 -0800 2010 Remove unnecessary comment for profane? method ... [adambair]
directory test/ Wed Jan 20 01:51:11 -0800 2010 test for profane?(nil) [thoughtless]
README.rdoc

Fu-fu: The Profanity Filter for Rails

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

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.

Install

  ./script/plugin install git://github.com/adambair/fu-fu.git

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 be replaced by value in config/dictionary.yml

  profanity_filter :foo, :bar, :method => 'vowels'
    #=> banned words will have their vowels replaced

  profanity_filter :foo, :bar, :method => 'hollow'
    #=> all letters except the first and last will be 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 be replaced by value in config/dictionary.yml

  profanity_filter! :foo, :bar, :method => 'vowels'
    #=> banned words will have their vowels replaced

  profanity_filter! :foo, :bar, :method => 'hollow'
    #=> all letters except the first and last will be replaced

You can also use the filter directly:

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

  ProfanityFilter::Base.profane?(text) #=> true/false

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

  • Turn this into a gem
  • May break ProfanityFilter out on it’s own
  • Clean up dictionary implementation and substitution (suboptimal and messy)
  • Move benchmarks into a rake task
  • Build out rdocs

License

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

Resources

Created by Adam Bair (adam@intridea.com) of Intridea (www.intridea.com) in the open source room at RailsConf 2008.

Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server