Created
June 30, 2012 19:14
-
-
Save JDLeigh10/3025144 to your computer and use it in GitHub Desktop.
Terminal Spell Check
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
# 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