Sha256: 981bfe902e0511e1e67065fa2cb101ebf580d04b96a94d0e5d296d24dd2588e4
Contents?: true
Size: 377 Bytes
Versions: 1
Compression:
Stored size: 377 Bytes
Contents
class String def word_count self.split(" ").length end def unique_words self.split(" ").uniq end def unique_word_count self.unique_words.length end def word_frequencies words = self.split(" ") word_frequencies = {} words.each do |word| word_frequencies[word.to_sym] ||= 0 word_frequencies[word.to_sym] += 1 end return word_frequencies end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
string-stats-es-0.1.0 | lib/string-stats-es.rb |