Class: Gluttonberg::Content::DespamilatorFilter::NumbersAndWords
- Inherits:
-
Gluttonberg::Content::Despamilator::Filter
- Object
- Gluttonberg::Content::Despamilator::Filter
- Gluttonberg::Content::DespamilatorFilter::NumbersAndWords
- Defined in:
- lib/gluttonberg/content/despamilator/filter/numbers_and_words.rb
Instance Method Summary collapse
Instance Method Details
#description ⇒ Object
33 34 35 |
# File 'lib/gluttonberg/content/despamilator/filter/numbers_and_words.rb', line 33 def description 'Detects unusual number/word combinations' end |
#name ⇒ Object
29 30 31 |
# File 'lib/gluttonberg/content/despamilator/filter/numbers_and_words.rb', line 29 def name 'Numbers next to words' end |
#parse(subject) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/gluttonberg/content/despamilator/filter/numbers_and_words.rb', line 9 def parse subject text = tidy_text(subject) [ /\w\d+/, /\d+\w/, /\d+($|\b)/ ].each do |regexp| matches = text.scan(regexp) next if matches.empty? matches.each do |to_remove| to_remove = to_remove.to_s text.sub!(to_remove, '') unless to_remove.empty? subject.register_match!({:score => 0.1, :filter => self}) end end end |