-
Notifications
You must be signed in to change notification settings - Fork 0
/
untitled2.py
36 lines (28 loc) · 1.05 KB
/
untitled2.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
# -*- coding: utf-8 -*-
"""Untitled2.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1lXGztRon3KHqN95SOcsohXZa3fb9lYOU
"""
# Description: This is a chat bot program
#import the library
from nltk.chat.util import Chat, reflections
pairs = [
['my name is (.*)', ['hi %1']],
['(hi|hello|hey|hola)', ['hey there', 'hi there', 'haayyy']],
['(.*) in (.*) is fun', ['%1 in %2 is indeed fun']],
['(.*)(location|city) ?', 'Delhi, India'],
['(.*) created you ?', ['abhishek did using NLTK']],
['how is the weather in (.*)', ['the weather in %1 is amazing like always']],
['(.*)help(.*)', ['I can help you']],
['(.*) your name ?', ['My name is J.A.R.V.I.S']],
['quit', ['Bye for now. See you soon :)', 'It was nice talking to you. See you soon :)']]
]
reflections
my_dummy_reflections = {
'go' : 'gone',
'hello' : 'hey there'
}
chat = Chat(pairs, my_dummy_reflections)
#chat._substitute('go hello')
chat.converse()