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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import random
|
| 2 |
+
import datetime
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
greetings = ["Hello there!"]
|
| 6 |
+
goodbyes = ["Bye!", "Goodbye!", "See you later!", "See you soon!"]
|
| 7 |
+
|
| 8 |
+
responses = {"hello": "How is your day going today?" ,
|
| 9 |
+
"hi": "How is your day going today?" ,
|
| 10 |
+
"bad": "bad to know :)",
|
| 11 |
+
"great": ":)",
|
| 12 |
+
"how about you": "I am very fine, thank you.",
|
| 13 |
+
"and you": "I am very fine, thank you.",
|
| 14 |
+
"what do you want to talk about": "we can talk about the art and jokes if you would like.",
|
| 15 |
+
"Great": ":)",
|
| 16 |
+
"not too well": "So sorry to hear that.",
|
| 17 |
+
"Fantastic": "Good for you!",
|
| 18 |
+
"good": "good to know :)",
|
| 19 |
+
"well": "good to know :)",
|
| 20 |
+
"So far so good!": "Glad to hear!",
|
| 21 |
+
"I'm fine": "Nice to know that you are fine",
|
| 22 |
+
"music": "Music is so relaxing!",
|
| 23 |
+
"pet": "Animals are such agreeable friends—they ask no questions; they pass no criticisms.",
|
| 24 |
+
"book": "I know about a lot of books.",
|
| 25 |
+
"game": "I like to play video games.",
|
| 26 |
+
"what can": "I can: talk about the weather, discuss art, tell you jokes, and inspire you.",
|
| 27 |
+
"weather": "The weather in Ohio is 66.66℉",
|
| 28 |
+
"joke": "What is the best thing about Swizterland? I don't know, but the flag is a big plus.",
|
| 29 |
+
"inspire": "Keep your face always toward the sunshine and shadows will fall behind you.", "movies": "I love to watch movies",
|
| 30 |
+
"sports" :"I follow the English Premier League very closely, my favorite team is Manchester United.",
|
| 31 |
+
"animal": "Did you know the only mammal capable of flight is the bat.",
|
| 32 |
+
"food": "Who doesn't love food? I love trying new cuisines and recipes.",
|
| 33 |
+
"hobbies": "In my free time, I enjoy playing sports, reading, and exploring the outdoors.",
|
| 34 |
+
"art": "Art is a powerful form of self-expression and has the ability to evoke deep emotions and spark conversation.",
|
| 35 |
+
"travel": "Travel is one of life's greatest joys. It broadens the mind and enriches the soul.",
|
| 36 |
+
"work": "Work provides purpose and meaning, and helps us to grow and develop new skills.",
|
| 37 |
+
"health": "Taking care of your health is one of the most important things you can do for yourself. Exercise, eat well, and get enough sleep.",
|
| 38 |
+
"technology": "Technology has revolutionized the way we live, work, and communicate. It's amazing what we can do with it.",
|
| 39 |
+
"fashion": "Fashion is a form of self-expression and can be a lot of fun. What's your favorite fashion trend?",
|
| 40 |
+
"nature": "Nature has a beauty and peace all its own. Take a walk outside and enjoy the fresh air and sunshine.",
|
| 41 |
+
"education": "Education is key to personal growth and success. Learning never ends and there is always more to discover."}
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
conversation_log = []
|
| 45 |
+
|
| 46 |
+
print(random.choice(greetings))
|
| 47 |
+
|
| 48 |
+
user = input("Say something (or type bye to quit): ")
|
| 49 |
+
user = user.lower()
|
| 50 |
+
|
| 51 |
+
while (user != "bye"):
|
| 52 |
+
conversation_log.append((datetime.datetime.now(), user))
|
| 53 |
+
keyword_found = False
|
| 54 |
+
for keyword in responses:
|
| 55 |
+
if keyword in user:
|
| 56 |
+
print("Bot: " + responses[keyword])
|
| 57 |
+
keyword_found = True
|
| 58 |
+
if keyword == "weather":
|
| 59 |
+
follow_up = input("Would you like to know the temperature of any other city? ")
|
| 60 |
+
if follow_up.lower() == "yes":
|
| 61 |
+
city = input("Which city would you like to know the temperature of? ")
|
| 62 |
+
print("Bot: The current temperature in " + city + " is 81℉")
|
| 63 |
+
if keyword == "music":
|
| 64 |
+
follow_up = input("Which genre of music you like to listen? ")
|
| 65 |
+
if follow_up.lower() == "pop":
|
| 66 |
+
print("Bot: I love pop music too! Some of my favorite pop artists are Taylor Swift and Ed Sheeran.")
|
| 67 |
+
elif follow_up.lower() == "rock":
|
| 68 |
+
print("Bot: Rock music is terrfic! Some of my favorite rock artists are AC/DC and Led Zeppelin.")
|
| 69 |
+
elif follow_up.lower() == "jazz":
|
| 70 |
+
print("Bot: Jazz is fantastic! Some of my favorite jazz artists are Duke Ellington and Louis Armstrong.")
|
| 71 |
+
elif follow_up.lower() == "classical":
|
| 72 |
+
print("Bot: Classical music is amazing! Some of my favorite classical compossers are Antonio Vivaldi and Ludwig van Beethoven.")
|
| 73 |
+
|
| 74 |
+
if keyword == "pet":
|
| 75 |
+
follow_up = input("Do you like dogs or cats? ")
|
| 76 |
+
if follow_up.lower() == "dog":
|
| 77 |
+
print("Bot: I love dogs too! Dogs are better than human beings because they know but do not tell. —Emily Dickinson")
|
| 78 |
+
elif follow_up.lower() == "cat":
|
| 79 |
+
print("Bot: I love cats too! They are independent and low maintenance. Do you wawnt to hear a joke about them?")
|
| 80 |
+
follow_up_joke = input()
|
| 81 |
+
if follow_up_joke.lower() == "yes":
|
| 82 |
+
print("What do you call a cat who loves to bowl? An alley cat!")
|
| 83 |
+
elif follow_up_joke.lower() == "no":
|
| 84 |
+
follow_up == print("OK")
|
| 85 |
+
if keyword == "book":
|
| 86 |
+
follow_up = input("Which genre of book you like to read? ")
|
| 87 |
+
if follow_up == "fantasy":
|
| 88 |
+
print("Bot: Fantasy books are great! Some of my favorite fantasy books are Harry Potter and Lord of the Rings.")
|
| 89 |
+
elif follow_up == "thriller":
|
| 90 |
+
print("Bot: Thriller books are interesting! Some of my favorite thriller books are The Girl on the Train and The Da Vinci Code.")
|
| 91 |
+
elif follow_up == "non-fiction":
|
| 92 |
+
print("Bot: Non-fiction books are works of art! Some of my favorite non-fiction books are Atomic Habits and Thinking, Fast and Slow.")
|
| 93 |
+
elif follow_up == "comics":
|
| 94 |
+
print("Bot: Comic books are fun to read! Some of my favorite comic books are Superman, Batman, Spider-Man, X-Men, Wonder Woman, The Avengers.")
|
| 95 |
+
|
| 96 |
+
if keyword == "art":
|
| 97 |
+
follow_up = input("""Select one of these a well known works of art to get an image to text description of the art piece.
|
| 98 |
+
- Starry night(1)
|
| 99 |
+
- The Persistence of Memory(2)
|
| 100 |
+
- Campbell's Soup Cans(3)
|
| 101 |
+
""")
|
| 102 |
+
if follow_up == "1":
|
| 103 |
+
print("""Bot: The Starry Night is a painting made in 1889 by Vincent Van Gogh:
|
| 104 |
+
|
| 105 |
+
The work, which is oil paint on canvas, is about 74 cm high and 92 cm wide.
|
| 106 |
+
It depicts a night sky with a crescent moon and starry night sky, as well as a quiet villageand a
|
| 107 |
+
large cypress tree in the foreground.The sky is the most dynamic part of the painting and is filled
|
| 108 |
+
with hundreds of short,thickly applied brushstrokes that give the appearance of roiling movement.
|
| 109 |
+
The tree is the nearest and darkest feature in the painting.The painting is considered remarkable
|
| 110 |
+
for its depiction of the sky and its ability to touch one's emotions.""")
|
| 111 |
+
elif follow_up == "2":
|
| 112 |
+
print("""Bot: "The Persistence of Memory" by Salvador Dali:
|
| 113 |
+
|
| 114 |
+
The Persistence of Memory is a painting made by Salvador Dali in 1931 using oil paint on canvas.
|
| 115 |
+
The work measures 24 inches by 33 inches, or 60 cm by 84 cm.It depicts a barren landscape with
|
| 116 |
+
several melting pocket watches draped over various objects.The watches symbolize the fluidity of
|
| 117 |
+
time and its effects on physical objects.""")
|
| 118 |
+
elif follow_up == "3":
|
| 119 |
+
print("""Campbell's Soup Cans by Andy Warhol: Made in 1962, this piece is a series of 32
|
| 120 |
+
canvases, each depicting a different flavor of Campbell's soup. Each canvas measures 20 inches tall and 16
|
| 121 |
+
inches wide, and is made using the silkscreen printing technique. The canvases are displayed in a grid formation,
|
| 122 |
+
creating a colorful and vibrant display.
|
| 123 |
+
|
| 124 |
+
The soup cans are rendered in bright, flat colors, with bold outlines and minimal shading. The labels on the cans
|
| 125 |
+
are clearly legible and include the flavor of the soup, the company name, and the familiar Campbell's logo.
|
| 126 |
+
The repetition of the images creates a mass-produced, commercial feel, reflecting Warhol's fascination with
|
| 127 |
+
popular culture and the rise of consumerism
|
| 128 |
+
in post-war America.""")
|
| 129 |
+
|
| 130 |
+
if keyword == "joke":
|
| 131 |
+
follow_up = input("Would you like to hear another one? y/n")
|
| 132 |
+
if follow_up == "y":
|
| 133 |
+
print("I invented a new word!...Plagiarism!")
|
| 134 |
+
input("Would you like to hear another one? y/n")
|
| 135 |
+
if follow_up == "y":
|
| 136 |
+
print("""Knock! Knock!
|
| 137 |
+
Who’s there?
|
| 138 |
+
Control Freak.
|
| 139 |
+
Con…
|
| 140 |
+
OK, now you say, “Control Freak who?” """)
|
| 141 |
+
input("Would you like to hear another one? y/n")
|
| 142 |
+
if follow_up == "y":
|
| 143 |
+
print("""Hear about the new restaurant called Karma?
|
| 144 |
+
There’s no menu: You get what you deserve.""")
|
| 145 |
+
input("Would you like to hear another one? y/n")
|
| 146 |
+
if follow_up == "y":
|
| 147 |
+
print("""Knock, knock.
|
| 148 |
+
Who's there?
|
| 149 |
+
Noble.
|
| 150 |
+
Noble who?
|
| 151 |
+
No bell, so I just knocked.""")
|
| 152 |
+
elif follow_up == "n":
|
| 153 |
+
print("Got it.")
|
| 154 |
+
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
|
| 158 |
+
|
| 159 |
+
break
|
| 160 |
+
|
| 161 |
+
if keyword_found == False:
|
| 162 |
+
new_keyword = input("I'm not sure how to respond. What keyword should I respond to? ")
|
| 163 |
+
new_response = input("How should I respond to " + new_keyword + "? ")
|
| 164 |
+
responses[new_keyword] = new_response
|
| 165 |
+
|
| 166 |
+
user = input("Say something (or type bye to quit): ")
|
| 167 |
+
user = user.lower()
|
| 168 |
+
if user == "bye":
|
| 169 |
+
break
|
| 170 |
+
conversation_log.append((datetime.datetime.now(), user))
|
| 171 |
+
|
| 172 |
+
print("Bot: Here is a summary of our conversation:")
|
| 173 |
+
for entry in conversation_log:
|
| 174 |
+
print(entry[0], entry[1])
|
| 175 |
+
|
| 176 |
+
print(random.choice(goodbyes))
|