15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/despamilator/filter/weird_punctuation.rb', line 15
def parse subject
text = subject.text.without_uris.downcase
text.gsub!(/\w&\w/, 'xx')
text.gsub!(/[a-z](!|\?)(\s|$)/, 'x')
text.gsub!(/(?:#{punctuation}){20,}/, '')
matches = text.remove_and_count!(/(?:\W|\s|^)(#{punctuation})/)
matches += text.remove_and_count!(/\w,\w/)
matches += text.remove_and_count!(/\w\w\.\w/)
matches += text.remove_and_count!(/\w\.\w\w/)
matches += text.remove_and_count!(/(#{punctuation})(#{punctuation})/)
matches += text.remove_and_count!(/(#{punctuation})$/)
matches += text.remove_and_count!(/(?:\W|\s|^)\d+(#{punctuation})/)
subject.register_match!({:score => 0.03 * matches, :filter => self}) if matches > 0
end
|