Created
July 6, 2013 11:48
Revisions
-
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ puts 'What is the name and path of the file?' filename = gets.chomp text = String.new File.open(filename) { |f| text = f.read } words = text.split(/[^a-zA-Z]/) freqs = Hash.new(0) words.each { |word| freqs[word] += 1 } freqs = freqs.sort_by {|x,y| y } freqs.reverse! freqs.each {|word, freq| puts word+' '+freq.to_s}