summaryrefslogtreecommitdiff
path: root/sample/freq.rb
blob: 0c433ae25a03c02252fe72db392d8888a7fc32e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
# word occurrence listing
# usege: ruby freq.rb file..
freq = {}
while gets()
  while sub(/\w+/, '')
    word = $&
    freq[word] +=1
  end
end

for word in freq.keys.sort
  printf("%s -- %d\n", word, freq[word])
end