Skip to content

Instantly share code, notes, and snippets.

@JDLeigh10
Created June 30, 2012 19:14
Show Gist options
  • Save JDLeigh10/3025144 to your computer and use it in GitHub Desktop.
Save JDLeigh10/3025144 to your computer and use it in GitHub Desktop.
Terminal Spell Check
# Load the dictionary, store it in an array
dictionary = File.open('dictionary.txt')
dictionary_array = dictionary.readlines
puts "<<< Terminal Spell Check >>>\n\n"
puts "Type in a word, and see if it is a valid English word\n"
print "> "
user_word = gets.chomp.downcase.strip
until user_word == 'quit'
if dictionary_array.include?("#{user_word}\r\n") == true
puts "YES!! #{user_word} is an English word\n\n"
else
puts "Nope, invalid word\n\n"
end
print "> "
user_word = gets.chomp.downcase.strip
end
puts "Goodbye!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment