class String def word_count frequencies = Hash.new(0) downcase.scan(/\w+/) { |word| frequencies[word] += 1 } return frequencies endend%{Dogs dogs dog dog dogs.}.word_count