-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathColon_Disease.py
270 lines (218 loc) · 8.8 KB
/
Colon_Disease.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
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
from Disease_CF import *
from Handling_Function import *
from fact_list import *
class getColon:
#Rule 128
@Rule(GoalisTo(action="getColon"),
NOT(Manifestaion(name=Clinic.ABDOMINAL_PAIN)),
)
@Rule(salience=priority-300)
def func_128(self):
ans=Handling_Choice_input("Do you Have [ABDOMINAL PAIN] ? ")
ans=get_the_Right_CF(ans)
self.declare(Manifestaion(name=Clinic.ABDOMINAL_PAIN,CF=ans))
#Rule 129
@Rule(GoalisTo(action="getColon"),
NOT(Manifestaion(name=Clinic.ABDOMINAL_PAIN_WORSE_BY_FOOD)),
Manifestaion(name=Clinic.ABDOMINAL_PAIN,CF=MATCH.cf),
TEST(lambda cf:cf>0)
)
@Rule (salience=priority-301)
def func_129(self):
ans=Handling_Choice_input("Dose Pain Worsed by Food ?" )
ans=get_the_Right_CF(ans)
self.declare(Manifestaion(name=Clinic.ABDOMINAL_PAIN_WORSE_BY_FOOD,CF=ans))
#Rule 130
@Rule(GoalisTo(action="getColon"),
NOT(Manifestaion(name=Clinic.ABDOMINAL_PAIN_WORSE_BY_STRESS)),
Manifestaion(name=Clinic.ABDOMINAL_PAIN,CF=MATCH.cf),
TEST(lambda cf:cf>0)
)
@Rule (salience=priority-302)
def func_130(self):
ans=Handling_Choice_input("Dose Pain Worsed by strees ?" )
ans=get_the_Right_CF(ans)
self.declare(Manifestaion(name=Clinic.ABDOMINAL_PAIN_WORSE_BY_STRESS,CF=ans))
#Rule 131
@Rule(GoalisTo(action="getColon"),
NOT(Manifestaion(name=Clinic.ABDOMINAL_FLATULENCE)),
)
@Rule (salience=priority-303)
def func_131(self):
ans=Handling_Choice_input("Do you Have [ABDOMINAL FLATULENCE] ? ")
ans=get_the_Right_CF(ans)
self.declare(Manifestaion(name=Clinic.ABDOMINAL_FLATULENCE,CF=ans))
#Rule 134
@Rule (GoalisTo(action="getColon"),
NOT(Fact(name="diarrhea")),
NOT(Manifestaion(name=Clinic.CONSTIPATION))
)
@Rule(salience=priority-306)
def func_134(self):
ans=Handling_YES_NO_input("Do you Have [CONSTIPATION] ? " )
if ans!=0:
self.declare(Manifestaion(name=Clinic.CONSTIPATION,CF=1))
else:
ans=Handling_YES_NO_input("Do you Have [diarrhea] ? ")
if ans!=0:
self.declare(Manifestaion(name=Clinic.dIARRHEA,CF=1))
self.declare(Fact(name="diarrhea"))
#Rule 135
@Rule (AS.gol<<GoalisTo(action="getColon"),
AS.f0<<Manifestaion(name=Clinic.ABDOMINAL_PAIN,CF=MATCH.c0),
AS.f1<<Manifestaion(name=Clinic.ABDOMINAL_PAIN_WORSE_BY_FOOD,CF=MATCH.c1),
AS.f2<<Manifestaion(name=Clinic.ABDOMINAL_PAIN_WORSE_BY_STRESS,CF=MATCH.c2),
AS.f3<<Manifestaion(name=Clinic.ABDOMINAL_FLATULENCE,CF=MATCH.c3),
AS.f4<<Manifestaion(name=Clinic.CONSTIPATION,CF=MATCH.c4)
)
@Rule(salience=priority-306)
def func_135(self,f0,f1,f2,f3,f4,c0,c1,c2,c3,c4,gol):
print(135)
c0=c0*IBS[Clinic.ABDOMINAL_PAIN]
c1=c1*IBS[Clinic.ABDOMINAL_PAIN_WORSE_BY_FOOD]
c2=c2*IBS[Clinic.ABDOMINAL_PAIN_WORSE_BY_STRESS]
c3=c3*IBS[Clinic.ABDOMINAL_FLATULENCE]
c4=c4*IBS[Clinic.CONSTIPATION]
cf=CF(c0,c1)
cf=CF(cf,c2)
cf=CF(cf,c3)
cf=CF(cf,c4)
if check_Finish(cf):
self.declare(Answer(name=DISEASE.IBS,pro=cf))
self.retract(f0)
self.retract(f1)
self.retract(f2)
self.retract(f3)
self.retract(f4)
self.modify(gol,action="getAnother")
#Rule 136
@Rule (AS.gol<<GoalisTo(action="getColon"),
AS.f0<<Manifestaion(name=Clinic.ABDOMINAL_PAIN,CF=MATCH.c0),
AS.f1<<Manifestaion(name=Clinic.ABDOMINAL_PAIN_WORSE_BY_FOOD,CF=MATCH.c1),
AS.f2<<Manifestaion(name=Clinic.ABDOMINAL_PAIN_WORSE_BY_STRESS,CF=MATCH.c2),
AS.f3<<Manifestaion(name=Clinic.ABDOMINAL_FLATULENCE,CF=MATCH.c3),
AS.f4<<Manifestaion(name=Clinic.dIARRHEA,CF=MATCH.c4)
)
@Rule(salience=priority-307)
def func_136(self,f0,f1,f2,f3,f4,c0,c1,c2,c3,c4,gol):
print(136)
c0=c0*IBS[Clinic.ABDOMINAL_PAIN]
c1=c1*IBS[Clinic.ABDOMINAL_PAIN_WORSE_BY_FOOD]
c2=c2*IBS[Clinic.ABDOMINAL_PAIN_WORSE_BY_STRESS]
c3=c3*IBS[Clinic.ABDOMINAL_FLATULENCE]
c4=c4*IBS[Clinic.dIARRHEA]
cf=CF(c0,c1)
cf=CF(cf,c2)
cf=CF(cf,c3)
cf=CF(cf,c4)
if check_Finish(cf):
self.declare(Answer(name=DISEASE.IBS,pro=cf))
self.retract(f0)
self.retract(f1)
self.retract(f2)
self.retract(f3)
self.retract(f4)
self.modify(gol,action="getAnother")
#Rule 137
@Rule (AS.gol<<GoalisTo(action="getColon"),
AS.f0<<Manifestaion(name=Clinic.ABDOMINAL_PAIN,CF=MATCH.c0),
AS.f1<<Manifestaion(name=Clinic.ABDOMINAL_PAIN_WORSE_BY_FOOD,CF=MATCH.c1),
AS.f2<<Manifestaion(name=Clinic.ABDOMINAL_PAIN_WORSE_BY_STRESS,CF=MATCH.c2),
AS.f3<<Manifestaion(name=Clinic.ABDOMINAL_FLATULENCE,CF=MATCH.c3)
)
@Rule(salience=priority-308)
def func_137(self,f0,f1,f2,f3,c0,c1,c2,c3,gol):
print(137)
c0=c0*IBS[Clinic.ABDOMINAL_PAIN]
c1=c1*IBS[Clinic.ABDOMINAL_PAIN_WORSE_BY_FOOD]
c2=c2*IBS[Clinic.ABDOMINAL_PAIN_WORSE_BY_STRESS]
c3=c3*IBS[Clinic.ABDOMINAL_FLATULENCE]
cf=CF(c0,c1)
cf=CF(cf,c2)
cf=CF(cf,c3)
if check_Finish(cf):
self.declare(Answer(name=DISEASE.IBS,pro=cf))
self.retract(f0)
self.retract(f1)
self.retract(f2)
self.retract(f3)
self.modify(gol,action="getAnother")
#Rule 138
@Rule (AS.gol<<GoalisTo(action="getColon"),
AS.f1<<Manifestaion(name=Clinic.ABDOMINAL_PAIN_WORSE_BY_FOOD,CF=MATCH.c1),
AS.f2<<Manifestaion(name=Clinic.ABDOMINAL_PAIN_WORSE_BY_STRESS,CF=MATCH.c2),
AS.f3<<Manifestaion(name=Clinic.ABDOMINAL_FLATULENCE,CF=MATCH.c3)
)
@Rule(salience=priority-307)
def func_138(self,f1,f2,f3,c1,c2,c3,gol):
print(138)
c1=c1*IBS[Clinic.ABDOMINAL_PAIN_WORSE_BY_FOOD]
c2=c2*IBS[Clinic.ABDOMINAL_PAIN_WORSE_BY_STRESS]
c3=c3*IBS[Clinic.ABDOMINAL_FLATULENCE]
cf=CF(c1,c2)
cf=CF(cf,c3)
if check_Finish(cf):
self.declare(Answer(name=DISEASE.IBS,pro=cf))
self.retract(f1)
self.retract(f2)
self.retract(f3)
self.modify(gol,action="getAnother")
#Rule 139
@Rule (AS.gol<<GoalisTo(action="getColon"),
AS.f1<<Manifestaion(name=Clinic.ABDOMINAL_PAIN_WORSE_BY_FOOD,CF=MATCH.c1),
AS.f3<<Manifestaion(name=Clinic.ABDOMINAL_FLATULENCE,CF=MATCH.c3)
)
@Rule(salience=priority-308)
def func_139(self,f1,f3,c1,c3,gol):
print(139)
c1=c1*IBS[Clinic.ABDOMINAL_PAIN_WORSE_BY_FOOD]
c3=c3*IBS[Clinic.ABDOMINAL_FLATULENCE]
cf=CF(c1,c3)
if check_Finish(cf):
self.declare(Answer(name=DISEASE.IBS,pro=cf))
self.retract(f1)
self.retract(f3)
self.modify(gol,action="getAnother")
#Rule 140
@Rule (AS.gol<<GoalisTo(action="getColon"),
AS.f2<<Manifestaion(name=Clinic.ABDOMINAL_PAIN_WORSE_BY_STRESS,CF=MATCH.c2),
AS.f3<<Manifestaion(name=Clinic.ABDOMINAL_FLATULENCE,CF=MATCH.c3)
)
@Rule(salience=priority-309)
def func_140(self,f2,f3,c2,c3,gol):
print(140)
c2=c2*IBS[Clinic.ABDOMINAL_PAIN_WORSE_BY_STRESS]
c3=c3*IBS[Clinic.ABDOMINAL_FLATULENCE]
cf=CF(c2,c3)
if check_Finish(cf):
self.declare(Answer(name=DISEASE.IBS,pro=cf))
self.modify(gol,action="getAnother")
self.retract(f2)
self.retract(f3)
#Rule 141
@Rule (AS.gol<<GoalisTo(action="getColon"),
AS.f1<<Manifestaion(name=Clinic.ABDOMINAL_PAIN)
)
@Rule(salience=priority-310)
def func_141(self,f1,gol):
print(141)
self.retract(f1)
self.modify(gol,action="getAnother")
#Rule 141
@Rule (AS.gol<<GoalisTo(action="getColon"),
AS.f1<<Manifestaion(name=Clinic.ABDOMINAL_PAIN_WORSE_BY_FOOD)
)
@Rule(salience=priority-311)
def func_142(self,f1,gol):
print(142)
self.retract(f1)
self.modify(gol,action="getAnother")
#Rule 141
@Rule (AS.gol<<GoalisTo(action="getColon"),
AS.f1<<Manifestaion(name=Clinic.ABDOMINAL_PAIN_WORSE_BY_STRESS)
)
@Rule(salience=priority-312)
def func_143(self,f1,gol):
print(143)
self.retract(f1)
self.modify(gol,action="getAnother")