Sha256: 8a70b32f6caffe1398c61ad4c1db0abb9f2a214d72b09df9f4b0b8bd16845c33

Contents?: true

Size: 399 Bytes

Versions: 1

Compression:

Stored size: 399 Bytes

Contents

class String

	def word_count
		string = self.split(" ").length
	end

	def unique_words
		self.split(" ").uniq
	end

	def unique_word_count
		self.unique_words.length
	end

	def word_frequencies
		unique_words = self.unique_words
		all_words = self.split(" ")
		frequencies = {}

		unique_words.each do |word|
			frequencies[word.to_sym] = all_words.count(word)
		end
		return frequencies
	end	

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
string-stats-befr-0.0.0 lib/string-stats-befr.rb