RosettaCodeData/Task/Word-frequency/Sidef/word-frequency.sidef

15 lines
274 B
Plaintext

var count = Hash()
var file = File(ARGV[0] \\ '135-0.txt')
file.open_r.each { |line|
line.lc.scan(/[\pL]+/).each { |word|
count{word} := 0 ++
}
}
var top = count.sort_by {|_,v| v }.last(10).flip
top.each { |pair|
say "#{pair.key}\t-> #{pair.value}"
}