Class: Gluttonberg::Content::DespamilatorFilter::NaughtyWords
- Inherits:
-
Gluttonberg::Content::Despamilator::Filter
- Object
- Gluttonberg::Content::Despamilator::Filter
- Gluttonberg::Content::DespamilatorFilter::NaughtyWords
- Defined in:
- lib/gluttonberg/content/despamilator/filter/naughty_words.rb
Instance Method Summary collapse
- #description ⇒ Object
- #local_parse(subject) ⇒ Object
- #name ⇒ Object
- #naughty_words ⇒ Object
- #parse(subject) ⇒ Object
Instance Method Details
#description ⇒ Object
13 14 15 |
# File 'lib/gluttonberg/content/despamilator/filter/naughty_words.rb', line 13 def description 'Detects cheeky words' end |
#local_parse(subject) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/gluttonberg/content/despamilator/filter/naughty_words.rb', line 34 def local_parse subject local_score = 0.0 unless subject.blank? text = subject.downcase naughty_words.each do |word| position = (text =~ /\b#{word}s?\b/) local_score += 0.1 if !position.blank? && position >= 0 end gb_blacklist_settings = Gluttonberg::Setting.get_setting("comment_blacklist") unless gb_blacklist_settings.blank? gb_blacklist_settings_words = gb_blacklist_settings.split(",") gb_blacklist_settings_words.each do |word| local_score += 1.0 if text.include?(word.strip.downcase) end end end local_score end |
#name ⇒ Object
9 10 11 |
# File 'lib/gluttonberg/content/despamilator/filter/naughty_words.rb', line 9 def name 'Naughty Words' end |
#naughty_words ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/gluttonberg/content/despamilator/filter/naughty_words.rb', line 55 def naughty_words words = %w{ underage penis viagra bondage cunt fuck shit dick tits nude dicks shemale dildo porn cock pussy clit preteen lolita } end |
#parse(subject) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/gluttonberg/content/despamilator/filter/naughty_words.rb', line 17 def parse subject text = subject.text.downcase naughty_words.each do |word| subject.register_match!({:score => 0.1, :filter => self}) if text =~ /\b#{word}s?\b/ end gb_blacklist_settings = Gluttonberg::Setting.get_setting("comment_blacklist") unless gb_blacklist_settings.blank? gb_blacklist_settings_words = gb_blacklist_settings.split(",") gb_blacklist_settings_words.each do |word| position = (text =~ /\b#{word.strip.downcase}s?\b/) subject.register_match!({:score => 1.0, :filter => self}) if !position.blank? && position >= 0 end end end |