Class: Wikipedia::VandalismDetection::Features::RemovedMarkupFrequency
- Defined in:
- lib/wikipedia/vandalism_detection/features/removed_markup_frequency.rb
Overview
This feature computes the frequency of markup words in the removed text.
Instance Method Summary collapse
-
#calculate(edit) ⇒ Object
Returns the percentage of markup words in the removed text.
Methods inherited from Base
Instance Method Details
#calculate(edit) ⇒ Object
Returns the percentage of markup words in the removed text. Returns 0.0 if cleaned removed text is of zero length.
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/wikipedia/vandalism_detection/features/removed_markup_frequency.rb', line 14 def calculate(edit) super text = edit.removed_text all_words_count = edit.removed_words.count regex = /(#{WordLists::MARKUP.join('|')})/ markup_words_count = text.scan(regex).count (all_words_count > 0) ? (markup_words_count.to_f) / (all_words_count.to_f) : 0.0 end |