Created
July 29, 2015 16:07
-
-
Save blake41/3eb70b6bd4ef16b8bce7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sentence = <<-something | |
Steven likes the movies. Blake likes to ride his bike but hates movies. | |
Blake is taller than steven. Steven is a great teacher. | |
something | |
sentence = sentence.gsub("."," ") # you can chain more then one gsub | |
sentence = sentence.split(" ").collect {|word| word.capitalize} | |
cont = {} | |
sentence.each do |filler| | |
cont[filler] = 0 | |
end | |
cont.each_pair do |word,number_of_occ| | |
sentence.each do |anotherword| | |
if word == anotherword | |
cont[word] = cont[word] + 1 | |
end | |
end | |
end | |
binding.pry |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment