+ class Base < String
+ include ActionView::Helpers::TagHelper
+
+ def spam_score
+ link_count = 0
+ link_size = 0
+
+ doc = Nokogiri::HTML(to_html)
+
+ if doc.content.empty?
+ link_proportion = 0
+ else
+ doc.xpath("//a").each do |link|
+ link_count += 1
+ link_size += link.content.length
+ end
+
+ link_proportion = link_size.to_f / doc.content.length.to_f
+ end
+
+ [link_proportion - 0.2, 0.0].max * 200 + link_count * 40