Skip to content

Commit

Permalink
Word frequency
Browse files Browse the repository at this point in the history
  • Loading branch information
Praveenkumar committed Apr 4, 2017
1 parent cf9393a commit 5b5e45f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions word_frequency.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
puts "enter the string"
str = gets.chomp

wrd_frequencies = Hash.new(0)

str.scan(/\w+/).each{|wrd| wrd_frequencies[wrd] += 1}

wrd_frequencies.each{|word, count| puts "#{word}-->#{count}"}

0 comments on commit 5b5e45f

Please sign in to comment.