Created
December 1, 2013 05:30
-
-
Save shunfan/7728842 to your computer and use it in GitHub Desktop.
Word Count
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_count(content) | |
result = Hash.new(0) | |
content.downcase.scan(/\w+/) { |word| result[word] += 1 } | |
result | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment