Class: Wikipedia::VandalismDetection::Features::CharacterSequence
- Defined in:
- lib/wikipedia/vandalism_detection/features/character_sequence.rb
Overview
This feature computes the length of the longest sequence of the same character in the inserted text.
Instance Method Summary collapse
Methods inherited from Base
Instance Method Details
#calculate(edit) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/wikipedia/vandalism_detection/features/character_sequence.rb', line 10 def calculate(edit) super sequence_hash = edit.inserted_text.scan(/((.)\2*)/).group_by{ |s, c| s.length } sequence_hash.empty? ? 0 : sequence_hash.max.first end |