Sha256: 9e8489700057dcb24ad67ad1499c8798c151b1ff34fb939b1a1dec60578ecf85

Contents?: true

Size: 416 Bytes

Versions: 1

Compression:

Stored size: 416 Bytes

Contents

class String

def word_count
	arr = self.split(" ")
	return arr.length
end

def word_frequencies
	arr = self.split(" ")
	arr.sort!
	histogram = Hash.new(0)
	arr.each do |word|
		histogram[word.downcase.to_sym] += 1
	end
	return histogram
end


def unique_words
	hash = self.word_frequencies
	arr = []
	hash.each_key { |key| arr << key.to_s }
	return arr
end

def unique_word_count
	self.unique_words.length
end


end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
string-stats-ah-0.1.0 lib/string-stats-ah.rb