Last active
August 29, 2015 14:08
-
-
Save danielbonnell/6bc396be106572597cee to your computer and use it in GitHub Desktop.
Shakespeare Challenge
This file contains 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 characters
def word_frequency(sample_file) | |
count = Hash.new(0) | |
IO.readlines(sample_file).each do |line| | |
line.split(/[\W\s]/).each do |word| | |
count[word.downcase] += 1 | |
end | |
end | |
count | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment