Created
August 9, 2019 07:22
-
-
Save skalibog/aed1d3618d56c9f84984293a7e526c62 to your computer and use it in GitHub Desktop.
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 characters
def parse(text) | |
arr = text.split(/[,.!? ]/).reject(&:empty?) | |
a = arr.map(&:downcase).each_with_object(Hash.new(0)) do |k, v| | |
v[k] += 1 | |
end | |
return [] if a.count < 3 | |
p a.sort_by { |_, v| v }.reverse[0...3] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment