/
nltk-basic-chatbot.py
62 lines (55 loc) 路 1.58 KB
/
nltk-basic-chatbot.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import nltk
from nltk.chat.util import Chat,reflections
# print(reflections)
set_pairs = [
[
r"my name is (.*)",
["Hello %1, How are you doing today ?",]
],
[
r"hi|hey|hello",
["Hello", "Hey there",]
],
[
r"what is your name?",
["You can call me a chatbot ?",]
],
[
r"how are you ?",
["I am fine, thank you! How can i help you?",]
],
[
r"I am fine, thank you",
["great to hear that, how can i help you?",]
],
[
r"how can i help you? ",
["i am looking for online guides and courses to learn data science, can you suggest?", "i am looking for data science training platforms",]
],
[
r"i'm (.*) doing good",
["That's great to hear","How can i help you?:)",]
],
[
r"i am looking for online guides and courses to learn data science, can you suggest?",
["Pluralsight is a great option to learn data science. You can check their website",]
],
[
r"thanks for the suggestion. do they have great authors and instructors?",
["Yes, they have the world class best authors, that is their strength;)",]
],
[
r"(.*) thank you so much, that was helpful",
["Iam happy to help", "No problem, you're welcome",]
],
[
r"quit",
["Bye, take care. See you soon :) ","It was nice talking to you. See you soon :)"]
],
]
def chatbot():
print("Hi, I'm the chatbot you built")
chat=Chat(set_pairs,reflections)
chat.converse()
if __name__ == "__main__":
chatbot()