Created
October 9, 2013 01:37
-
-
Save chug2k/6894803 to your computer and use it in GitHub Desktop.
Simple conversation bot
This file contains 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
# We're going to write a very simple conversation bot. | |
def get_response(prompt) | |
if prompt.include?("hello") | |
"Hello! How are you?" | |
elsif prompt.include?("bye") | |
"Bye! It was great talking to you!" | |
else | |
"I do not understand what you mean by: \"#{prompt}\"" | |
end | |
end | |
puts "Hello, I am a computer." | |
while true | |
print '> ' | |
puts get_response(gets.strip.downcase) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment