-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
104 lines (99 loc) · 4.06 KB
/
main.py
File metadata and controls
104 lines (99 loc) · 4.06 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import re
import json
from lib import *
from lib2 import *
from random import *
from time import *
data = {"who are teachers": "I simple say god",
"who are you": "I'm your friend you can ask me questions and i try to answer them byut may not know all of them but sure learn it with you",
"do you have a teacher": "No, but you can be my teacher by just teaching me what I dont know",
"who old are you": "I was born when you ran the my program",
"do you have frinds": "Yes its you!!!!!",
"can you eat": "No I only take data as my food",
"why is teachers day celebrated": "The birth date of the second President of India, Sarvepalli Radhakrishnan, 5 September 1888, has been celebrated as Teacher's Day since 1962.",
"when is teachers day celebrated": "Globally, Teachers Day is celebrated on 5th October; in India, we celebrate it on 5th September from 1962 onwards.",
"who is the greatest teacher in india": "Your best teacher is your last mistake,” Kalam said.",
"who started teachers day in india": "Dr Sarvepalli Radhakrishnan said 'Instead of celebrating my birthday, it would be my proud privilege if September 5 is observed as Teachers Day' he said"
}
funcdict = {
"stop speaking":stopSpeak,
"speak":startSpeak,
"find lowest common multiple": math_functions.LowestCommonMultiple,
"roll a dice": roll_a_dice,
"open file": open_file,
"subtract number": sub,
"toss a coin": toss,
"add numbers": add,
"search": search,
"give me some dumy text": dumy,
"dumy": dumy,
"help": helpx,
"find square": square,
"find square root": squareroot,
"time": date_time.time,
"date": date_time.date,
"encrypt": cryptography.encrypt,
"decrypt": cryptography.decrypt,
"find common factors": math_functions.commonfactors,
"find factors": math_functions.factors,
"isprime": math_functions.isPrime,
"find highest common factor": math_functions.highestCommonFactor,
"find multiples": math_functions.multiples,
"find nearest perfect square": math_functions.NearestPerfectSquare,
"is perfect square": math_functions.IsPerfectSquare,
"find lowest Form": math_functions.lowestForm,
"riddle": riddle,
"read": read_this
}
great = ["Thankyou", "So nice of you", "I appreciate for your help", "thank you very much",
"I thank you from the bottom of my heart. Yes, I do have it", "accept my endless gratitude", "thanks a lot"]
say("Hi, I'm your friend you can ask me questions but not sure I can answer all ")
say("If you are enough having fun with me say 'stop' ")
print("loading database")
tdata = load_database()
mainlist = [funcdict, data]
while True:
s = ask('say somthing')
i = re.sub("\s\s+", " ", s)
if i == "stop" or i == "s":
break
if i == '':
say("you didnt enter anything")
continue
status = False
if i == "test":
for key, values in funcdict.items():
say(key)
values()
for data in mainlist:
if mainlist.index(data) == 0:
if data.get(i):
data.get(i)()
status = True
elif data.get(i):
say(data.get(i))
data.get(i)()
status = True
if status == False:
if tdata.get(i):
say(tdata.get(i))
else:
say(
"I dont know the answer can you help me!!, you can ask me the answer or say sorry")
a = ask("help me with answer :")
if not(a in ["sorry","s","no"]) :
say(choice(great))
tdata[i] = a
save_database(tdata)
else:
say("its ok")
review = ask("how was your experience?:")
path = find_database_path()
with open(path, "r") as jsonFile:
data = json.load(jsonFile)
data["user_review"].append(review)
with open(path, "w") as jsonFile:
json.dump(data, jsonFile, indent=4)
say("saving database")
save_database(tdata)
say(choice(great))