-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhassanwari.pl
103 lines (84 loc) · 3.42 KB
/
hassanwari.pl
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
notice:-
write('This is an Example of a Disease Diagnosis Artificial intelligence System for Diagnosing some Lung Diseases'),nl,
write('This system has been designed by Hassan_Wari'),nl,
nl,
write('To use it, just answer the quizes the AI systems asks you.'),nl,
nl.
%hypothesises
disease(Patient,tuberculosis):-
symptom(Patient, persistent_cough),
symptom(Patient, constant_fatigue),
symptom(Patient, weight_loss),
symptom(Patient, lack_of_appetite),
symptom(Patient, fever),
symptom(Patient, coughing_blood),
symptom(Patient, night_sweats).
disease(Patient,pneumonia):-
symptom(Patient, cough),
symptom(Patient, fever),
symptom(Patient, shaking_chills),
symptom(Patient, shortness_of_breath),
disease(Patient,byssinosis):-
symptom(Patient, chest_tightness),
symptom(Patient, cough),
symptom(Patient, wheezing).
disease(Patient,pertusis):-
symptom(Patient, runny_nose),
symptom(Patient, mild_fever).
disease(Patient,pneumoconiosis):-
symptom(Patient,chronic_cough),
symptom(Patient,shortness_of_breath).
disease(Patient,sarcoidosis):-
symptom(Patient, dry_cough),
symptom(Patient, shortness_of_breath),
symptom(Patient, mild_chest_pain),
symptom(Patient, scaly_rash),
symptom(Patient, fever),
symptom(Patient, red_bumps_on_legs),
symptom(Patient, sore_eyes),
symptom(Patient, swollen_ankles).
disease(Patient,asbestosis):-
symptom(Patient, chest_tightness),
symptom(Patient, shortness_of_breath),
symptom(Patient, chest_pain),
symptom(Patient, lack_of_appetite).
disease(Patient,asthma):-
symptom(Patient, wheezing),
symptom(Patient, cough),
symptom(Patient, chest_tightness),
symptom(Patient, shortness_of_breath).
disease(Patient,bronchiolitis):-
symptom(Patient, wheezing),
symptom(Patient, fever),
symptom(Patient, blue_skin),
symptom(Patient, rapid_breath).
disease(Patient,influenza):-
symptom(Patient, headache),
symptom(Patient, fever),
symptom(Patient, shaking_chills),
symptom(Patient, nasal_congestion),
symptom(Patient, runny_nose),
symptom(Patient, sore_throat).
disease(Patient,lung_cancer):-
symptom(Patient, cough),
symptom(Patient, fever),
symptom(Patient, hoarseness),
symptom(Patient, chest_pain),
symptom(Patient, wheezing),
symptom(Patient, weight_loss),
symptom(Patient, lack_of_appetite),
symptom(Patient, coughing_blood),
symptom(Patient, headache),
symptom(Patient, shortness_of_breath).
/*Ask rules*/
symptom(P, Val):-ask('Does the Patient have',Val).
ask(Obj, Val):-known(Obj, Val, true),!.
ask(Obj, Val):-known(Obj, Val, false),!, fail.
ask(Obj, Val):-nl,write(Obj),write(' '),
write( Val) , write('?(y/n)'), read(Ans), !,
((Ans=y, assert(known(Obj, Val, true)));(assert(known(Obj, Val, false)),fail)).
diagnose:-nl,write('Diagnosing a lung disease..........'),nl,disease(symptom,Disease) ,!,nl,
write('That lung disease could be '), write(disease).
diagnose:- nl, write('Sorry,we may not be able to diagnose the desease!!').
start:-notice,repeat, abolish(known/3),dynamic(known/3), retractall(known/3), diagnose,nl,nl, write('Try again ? (y/n)'),read(Resp),\+ Resp=y,
nl,write('GoodBye ! Thank you for using this system and we hope to see you soon'),abolish(known,3) .