Class: Wikipedia::VandalismDetection::Features::LongestWord
- Defined in:
- lib/wikipedia/vandalism_detection/features/longest_word.rb
Overview
This feature computes the length of the longest word in the inserted text.
Instance Method Summary collapse
Methods inherited from Base
Instance Method Details
#calculate(edit) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/wikipedia/vandalism_detection/features/longest_word.rb', line 11 def calculate(edit) super sequence_hash = Text.new(edit.inserted_words.join("\n")).clean.split(/[\b\s+,;:]/).group_by(&:length) sequence_hash.empty? ? 0 : sequence_hash.max.first end |