summaryrefslogtreecommitdiff
path: root/sample/occur.rb
blob: 2141fade38d3c6f678ddaaa59af470af636700d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
# word occurrence listing
# usege: ruby occur.rb file..
freq = {}
while gets()
  for word in $_.split(/\W+/)
    freq[word] +=1
  end
end

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