Rails Slide Filter?

I did a few searches and I could not find any open source lame filter for rails. Is there anything similar? I am trying to limit lame user-created content, in particular, all caps, improper capitalization, excessive exclamation points, and excessive bold or italics.

+3
source share
2 answers

Here's a ruby Bayesian classifier that can be taught to block certain types of content. This will require some creativity to apply directly to your problem.

This is a commercial service, but SocialMod is worth mentioning.

+2

, . - .

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

demerit , .

+2

Source: https://habr.com/ru/post/1720714/


All Articles