Skip to content

Instantly share code, notes, and snippets.

@gfmurphy
Created April 16, 2013 13:56
Show Gist options
  • Save gfmurphy/5396083 to your computer and use it in GitHub Desktop.
Save gfmurphy/5396083 to your computer and use it in GitHub Desktop.
Find top 16 most freq. occurring words greater than 4 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