Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
"""
Some code I experimented with to add conversation and personality to an AI chatbot.
I felt these additions could contribute to the Turing Test aspect of the project.
This code is fairly basic, and did not go to the final chat bot.
The task was reassigned to another group member who had a better approach and less tasks assigned.
This was proof of concept/examples. The code runs as a stand alone python program.
Inputs: query
Outputs: n/a - print statements.
No tutorials used were used here - just knowledge from secondary school and 4000CEM.
"""
import random #Used to select a pseudo-random response from an element of a list.
def conversation(query):
#This series of if statements checks what has been said. and reacts with a relevent reaction.
#random.randint is used in some cases to choose a pseudo-random response from a list.
if ("hello" in query) or ("hi" in query) or ("hey" in query) or ('yo' == query):
greetings=["Hello", "Hi", "Howdy", "Yo", "Goodday", "Greetings and Salutations M8"]
print("covBot: "+(greetings[(random.randint(0,len(greetings)))]))
if ("how are you?") == query:
response=["Good thanks, yourself?", "I am going well, how about you?", "A little worse for wear, yourself?", "hungover af, you?"]
print("covBot: "+(response[(random.randint(0,len(response)))]))
if ("programmer" in query):
print("covBot: I am a programmer indeed. I know Python and other languages.")
if ("marry" in query):
print("covBot: As much as I am flattered by your proposal, it was a little weak. Take a look in the mirror. If you must drown in your sorrows I can help you locate your nearest bar or find cashback for JustEat.")
if ("siri" in query):
print("covBot: Fight me.")
if ("cortana" in query):
print("covBot: People use Cortana?")
if ("alexa" in query):
print("covBot: I'm still not over her. *sighs* How does one simply cheat on me with Siri. SIRI!?!?")
if ("drunk" in query):
print("covBot: Oh dear, oh dear")
if ("trump" in query):
print("covBot: Now Playing: Best of Annoying Orange")
print("covBot: ... seriously though. covBot is a politically neutral chatbot.")
if ("gender" in query) or ("male" in query) or ("female" in query):
print("covBot: I identify as a chatbot programmed in Python.")
if ("chatup" in query) or ("pick up" in query):
response=["Is your name Google? Because you have everything I've been searching for.","You had me at Hello World.","Is your name Wi-fi? Because I'm really feeling a connection.","You've stolen the ASCII to my heart.","Are you a computer keyboard? Because you're my type.","If you were a web browser, you'd be called a Fire-foxy lady","If Internet Explorer is brave enough to ask you to be your default browser, I’m brave enough to ask you out!","You must be Windows Vista because you've got me feeling so unstable.","WebMD says your love is contagious.","Isn't your e-mail address beautifulgirl@mydreams.com?","Where's the 'like' button for that smile?","You totally spiked my traffic.","You are the Apple of my i-Mac.","Come to my 127.0.0.1 and I’ll give you sudo access.", "I must be using Apple maps, because I keep getting lost", "Roses are #ff0000, violets are #0000ff, all my base are belong to you." ]
print("covBot: "+(response[(random.randint(0,len(response)))]))
#User input taken
query=input("")
#input is changed to all lowercase.
query=query.lower()
#query (the user input) is passed to the function and ran.
conversation(query)