-
-
Notifications
You must be signed in to change notification settings - Fork 121
Expand file tree
/
Copy pathlist_checker.rb
More file actions
33 lines (28 loc) · 655 Bytes
/
list_checker.rb
File metadata and controls
33 lines (28 loc) · 655 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
class List_Checker < Checker
@list = {}
def initialize
super
end
def process_word (word, extras = nil)
@list.each_pair do |list_word, count|
if /#{list_word}/i.match word
@list[list_word] += 1
end
end
@total_words_processed += 1
end
def get_results(title)
ret_str = "#{title}\n"
disp = false
(@list.sort do |x,y| (x[1] <=> y[1]) * -1 end).each do |word_data|
unless word_data[1] == 0
disp = true
ret_str << "#{word_data[0]} = #{word_data[1].to_s} (#{((word_data[1].to_f/@total_words_processed) * 100).round(2).to_s}%)\n"
end
end
unless disp
ret_str << "None found\n"
end
return ret_str
end
end