-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCode:)
More file actions
38 lines (33 loc) · 968 Bytes
/
Code:)
File metadata and controls
38 lines (33 loc) · 968 Bytes
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
# Description: This is a chat bot
#import the library
from nltk.chat.util import Chat, reflections
pairs = [
['my name is (.*)',['hi %1']],
['(hi|hello|hey|hola|hollaa)', ['hey there', 'hi there', 'haayyy']],
['(.*) in (.*) is fun', ['%1 in %2 is indeed fun']],
['(.*)(location|city) ?', 'Bengaluru, Chennai'],
['(.*)created you ?', ['theservermonk using NLTK']],
['(.*) is the weather in (.*)', ['the weather in %1 is amazing like always']],
['(.*)help(.*)',['I can help you']],
['(.*) your name ?', ['my name is ladyPy']]
]
my_dummy_reflections = {
'go' : 'gone',
'hello' : 'hey there'
}
chat = Chat(pairs, my_dummy_reflections)
#chat._substitute('go hello')
chat.converse()
Output:
>hi
haayyy
>whats the weather in Chennai?
None
>what is the weather in Chennai?
the weather in what is amazing like always
>who created you
theservermonk using NLTK
>Whats your name?
my name is ladyPy
>can you help me out?
I can help you