Coder Social home page Coder Social logo

justincinmd / validates_lameness_of Goto Github PK

View Code? Open in Web Editor NEW
2.0 3.0 0.0 88 KB

Rails plugin that provides a number of validations that will check strings for lameness.

Home Page: http://rdoc.info/projects/jcnnghm/validates_lameness_of

License: MIT License

Ruby 100.00%

validates_lameness_of's Introduction

ValidatesLamenessOf

ValidatesLamenessOf is a plugin that I developed to assist in clearing up some of the negative behavior shown in our user comments. I’ve observered that user’s that exhibit a set of behaviors, are likely to exhibit many more. In other words, a good user is likely to leave a comment like “This is a good comment”, whereas a bad user is likely to write something like “OMG THIS IS SOU FUNNY!!!!!! :) lol xoxo”. While the first isn’t really lame at all, the second is lame in many different ways.

The idea behind this plugin is that if we filter for obviously lame things, like an abundance of ALL CAPS words, or excessive exclamation marks, we can use these lame and non-lame comments to train a Bayesian filter to automatically classify comments over time as the definition of lameness evolves. Comments can presently be reported for filtering, although there doesn’t yet exist a validation to check against the filter, as further testing is needed. Over time, additional lameness reporting validations will be added as user behaviors change.

Installation

ValidatesLamenessOf is available as a traditional plugin. To install it as a traditional plugin (Rails 2.1 or later):

script/plugin install git://github.com/jcnnghm/validates_lameness_of.git

To use the bayesian filtering, you’ll need to install the classifier gem, and the madeleine gem. To do this, add the following to your environment.rb, then run rake gems:install.

config.gem 'classifier'
config.gem 'madeleine'

Example

The validations work like any other validation.

class Comment < ActiveRecord::Base
  validate_capitilization_of :comment, :minimum_size => 5, :maximum_uppercase_percentage => 40, :report_lameness => true
  validate_exclamation_marks_of :comment, :maximum_in_composition => 2, :maximum_together => 1, :report_lameness => true
end

The only difference is the report_lameness option, which, when set to true, will automatically train a bayesian filter for each field.

Configuration

You may need to configure ValidatesLamenessOf for your setup. The configuration required is:

data_directory

String that sets the directory that will be used to store persisted bayesian filter data. In your production environment, you will probably want to set this somewhere that persists between deployments.

ValidatesLamenessOf.data_directory = 'tmp/lameness_data' # sets for current environment (also the default)

Resources

Credits

Based, in part, on the following:

Copyright © 2009 Justin Cunningham, released under the MIT license

validates_lameness_of's People

Stargazers

 avatar  avatar

Watchers

 avatar  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.