Created
April 16, 2013 13:56
-
-
Save gfmurphy/5396083 to your computer and use it in GitHub Desktop.
Find top 16 most freq. occurring words greater than 4 characters
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
paragraphs.join("\n").split(/\W/) | |
.reject { |w| w.size < 4 } | |
.map(&:downcase) | |
.reduce(Hash.new(0)) { |words, word| words[word] += 1; words } | |
.sort { |a, b| a.last <=> b.last } | |
.take(16) | |
.map(&:first) | |
.join(' ') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment