views:

184

answers:

2

I've done some searching, and I haven't been able to find any kind of open-source lameness filter for rails. Does anything like that exist? I'm trying to curtail lame user generated content, in particular, all caps, improper capitalization, excessive exclamation marks, and excessive bold or italics.

+2  A: 

Here is a ruby Bayesian Classifier which can be trained to block certain types of content. It would take some creativity to apply directly to your problem.

Its a commercial service, but SocialMod is worth a mention.

jrhicks
Looks like SocialMod just outsources moderation, not quite the filter jcnnghm is looking for.
EmFi
Bayesian filtering certainly seems interesting. I'm sure that would work well, given that if a person does one thing that would trip my lameness filter, they are usually doing several. Does anyone know of a way to persist the classifications with the listed plugin.
jcnnghm
SnapshotMadeleine can persist the classifier.
jrhicks
I created a rails plugin that uses a set of validations to train a Bayesian filter that can then be used to classify fields. The source code is available at http://github.com/jcnnghm/validates_lameness_of. Thank's for the advice.
jcnnghm
+2  A: 

I don't know of any existing ones, but it should be too hard to catch most of these with a set of regular expressions in a custom validation. Improper capitalization is a hard one to catch because of proper names and acronyms.

before_validation :filter_lameness

def filter_lameness
  # reduce exclamation marks
    content.gsub!(/![!1]+/, "!")
  # Proper capitalization. 
    content.gsub!(/(\.\s*[a-z])/, $1.upcase) # capital starts sentence
    content.gsub!(/([A-Z]{5,})/, $1.capitalize) # lowercases all but first letter in a string of capitals. Minimum length 5.
  # etc...
    return true # needed in case the last gsub matches nothing, otherwise validation returns nil and will fail
end

Personally I'd be tempted to keep track of users' infractions to the style guide and pin them with demerit badges after enough offenses, for public humliation.

EmFi