generated from github/codespaces-blank
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAI-Chat.py
40 lines (38 loc) · 931 Bytes
/
AI-Chat.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import nltk
from nltk.chat.util import Chat, reflections
pairs = [
[
r"my name is (.*)",
["Hello %1, how can I assist you today?"]
],
[
r"hi|hello|hey",
["Hello!", "Hi there!"]
],
[
r"what can you do|what are your capabilities",
["I can help you with general queries, tell jokes, or play a game with you."]
],
[
r"tell me a joke",
["Why don't scientists trust atoms? Because they make up everything!"]
],
[
r"play a game",
["Sure, let's play a guessing game. I'm thinking of a number between 1 and 10. What is it?"]
],
[
r"([0-9]*)",
[
"Sorry, that's incorrect. Try again!",
"Nope, not quite. Guess again!",
"Wrong! Keep trying."
]
],
[
r"quit",
["Goodbye!"]
]
]
chatbot = Chat(pairs, reflections)
chatbot.converse()