#!/usr/bin/ruby # File: scrubbit.rb # Takes input from user and checks it against file of stop words. puts "Enter a phrase to scrub:" unscrubbed = gets.chomp! puts "Your phrase is #{unscrubbed}." filename = "small_goodwords.txt" if File.exists?(filename) then infile = File.open("#{filename}", "r") else puts "#{filename} not found" exit end #put the goodwords into a hash: good_hash = {} infile.each do |word| word.chomp! good_hash[word]=" " end word_array = unscrubbed.split word_array.each do |word| if good_hash.key?("#{word}") print word + " " else print "* " end end puts exit