Class: Wikipedia::VandalismDetection::Features::UpperToLowerCaseRatio
- Defined in:
- lib/wikipedia/vandalism_detection/features/upper_to_lower_case_ratio.rb
Overview
This feature computes the uppercase to all letters ratio of the edit’s new revision inserted text.
Instance Method Summary collapse
Methods inherited from Base
Instance Method Details
#calculate(edit) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/wikipedia/vandalism_detection/features/upper_to_lower_case_ratio.rb', line 10 def calculate(edit) super text = edit.inserted_text return 0.0 if text.empty? uppercase_count = text.scan(/[[:upper:]]/).size lowercase_count = text.scan(/[[:lower:]]/).size (1.0 + uppercase_count) / (1.0 + lowercase_count) end |