Sha256: fe149ece7eb42b79961a574d721361f393cb9faa980deb09856cac5f3a5281f0

Contents?: true

Size: 476 Bytes

Versions: 1

Compression:

Stored size: 476 Bytes

Contents



class String

def word_count
  # self.split(" ").count 
  split(" ").count
end

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

def unique_word_count
  # self.unique_words.count
  split(" ").uniq.count 
end

def word_frequencies
freq = {}
split(" ").each do |word|
  freq[word.to_sym] ||= 0
  freq[word.to_sym] += 1
  end
  freq 
# # dan's way of using regex
#   freq = {}
#   split(" ").scan(/\w+/) do |key|
#     words[key] += 1
#   end
#   freq
end

end

Version data entries

1 entries across 1 versions & 1 rubygems

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