blob: 5927ebc8891e04b7516aa268bc5c3e8c093d53bc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
|
# word occurrence listing
# usage: ruby occur.rb file..
freq = Hash.new(0)
while line = gets()
line.scan(/\w+/) do |word|
freq[word] += 1
end
end
for word in freq.keys.sort!
print word, " -- ", freq[word], "\n"
end
|