Class: Wikipedia::VandalismDetection::Features::ImpactBase
- Defined in:
- lib/wikipedia/vandalism_detection/features/impact_base.rb
Direct Known Subclasses
AllWordlistsImpact, BadImpact, BiasedImpact, PronounImpact, SexImpact, VulgarismImpact
Instance Method Summary collapse
-
#impact(old_text, new_text, terms) ⇒ Object
Returns the ratio of given text’s terms count.
Methods inherited from Base
Instance Method Details
#impact(old_text, new_text, terms) ⇒ Object
Returns the ratio of given text’s terms count. For impact calculation it returns 0.5 if number of terms in old text is zero.
11 12 13 14 15 16 17 |
# File 'lib/wikipedia/vandalism_detection/features/impact_base.rb', line 11 def impact(old_text, new_text, terms) old_terms_count = (count terms, in: old_text).to_f new_terms_count = (count terms, in: new_text).to_f no_terms_in_both = (old_terms_count == 0 && new_terms_count == 0) no_terms_in_both ? 0.5 : (old_terms_count / (old_terms_count + new_terms_count)) end |