forked from abhi608/Chatbot_project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInit
63 lines (57 loc) · 1.56 KB
/
Init
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
62
63
import sqlite3
connect = sqlite3.connect('data.sqlite')
cur = connect.cursor()
flag = 0
pal = 'Hello'
li1 = [pal]
user = ''
print('Pal: ', pal)
print('You: ')
user = input()
li = [user]
while user!='bye':
cur.execute('SELECT Response FROM sents WHERE Input=?;', li)
flag = 0
resp = cur.fetchone()
if not resp:
cur.execute('SELECT rowid FROM sents WHERE Input=?;', li1)
d = cur.fetchone()
flag = 3
if not d:
cur.execute('SELECT Input FROM sents WHERE Response IS NULL;')
resp = cur.fetchone()
flag = 1
cur.execute('INSERT INTO sents (Input) VALUES (?);', li)
if resp == None:
resp = 'Let us change the topic.'
flag = 2
if flag==0:
resp = resp[0]
print('Pal: ', resp)
li1 = [resp]
if flag==3:
d = d[0]
cur.execute('UPDATE sents SET Response =? WHERE rowid=?', (user, d))
cur.execute('SELECT Input FROM sents WHERE Response IS NULL;')
resp = cur.fetchone()
#cur.execute('INSERT INTO sents (Input) VALUES (?);', li)
if resp == None:
resp = 'Let us change the topic.'
li1 = ['']
else:
resp = resp[0]
li1 = [resp]
print('Pal: ', resp)
if flag==1:
resp = resp[0]
print('Pal: ', resp)
li1 = [resp]
if flag==2:
print('Pal: ', resp)
li1 = ['']
print('You: ')
user = input()
#print(flag)
li = [user]
connect.commit()
connect.close()