Class: Wikipedia::VandalismDetection::Features::SizeRatio
- Defined in:
- lib/wikipedia/vandalism_detection/features/size_ratio.rb
Overview
This feature computes the ratio of the edit’s revisions text length.
Instance Method Summary collapse
-
#calculate(edit) ⇒ Object
Returns the ration of new text length to old text length: returns 0.0 for empty old revision text, returns 1.0 for empty new revision text, returns 0.5 for both revision texts empty or same size computation: old / old + new.
Methods inherited from Base
Instance Method Details
#calculate(edit) ⇒ Object
Returns the ration of new text length to old text length: returns 0.0 for empty old revision text, returns 1.0 for empty new revision text, returns 0.5 for both revision texts empty or same size computation: old / old + new
15 16 17 18 19 20 21 22 |
# File 'lib/wikipedia/vandalism_detection/features/size_ratio.rb', line 15 def calculate(edit) super old_size = edit.old_revision.text.size.to_f new_size = edit.new_revision.text.size.to_f (old_size == 0 && new_size == 0) ? 0.5 : old_size / (old_size + new_size) end |