Code Improvement
Posted: 8 Mar 2023 9:49
Hi everyone,
I am about to finish my Thesis.
Can anyone tell me if this code need improvements ??
Any suggestions are welcome !!
Thanks
Code here:
I am about to finish my Thesis.
Can anyone tell me if this code need improvements ??
Any suggestions are welcome !!
Thanks
Code here:
Code: Select all
implement diagnoseRun
open core
class facts - factdb
xpositive : (symbol, symbol).
xnegative : (symbol, symbol) nondeterm.
clauses
positive(X, Y) :-
xpositive(X, Y),
!.
positive(X, Y) :-
not(xnegative(X, Y)),
question(X, Y).
clauses
question(X, Y) :-
!,
Reply = answerDialog::ask(string::concat(X, " it ", Y, "\n")),
% !,
C = string::charLower(string::frontChar(Reply)),
remember(X, Y, C).
clauses
remember(X, Y, Ans) :-
if Ans = 'y' then
assertz(xpositive(X, Y))
elseif Ans = 'n' then
assertz(xnegative(X, Y)),
fail
end if.
clear_facts() :-
retractFactDb(factDb).
%_Reply = stdio::readLine().
clauses
run() :-
disease(X),
!,
messageBox::displayNote(X, "The disease having all these symptoms is"),
clear_facts.
run() :-
messageBox::displayError("The disease cannot be determined."),
clear_facts.
clauses
disease('Covid-19') :-
is_disease('Covid-19').
disease('Pharyngitis') :-
is_disease('Pharyngitis').
disease('Flu') :-
is_disease('Flu').
disease('Common Cold') :-
is_disease('Common Cold').
disease('Pneumonia') :-
is_disease('Pneumonia').
disease('Menigitis') :-
is_disease('Menigitis').
clauses
is_disease('Covid-19') :-
positive('have', 'fever?'),
positive('feel', 'chest pain?'),
positive('have', 'lose of taste?'),
positive('have', 'lose of smell?'),
positive('have', 'cough?'),
positive('feel', 'difficulty breathing?'),
positive('have', 'diarrhea?'),
positive('have', 'vomiting?').
is_disease('Pharyngitis') :-
positive('have', 'sudden onset of sore throat?'),
positive('have', 'pain with swallowing?'),
positive('have', 'fever?'),
positive('have', 'cough?'),
positive('have', 'rhinorrea?'),
positive('have', 'hoarseness?'),
positive('have', 'oral ulcers?'),
positive('have', 'conjuctivitis?').
is_disease('Flu') :-
positive('have', 'fever?'),
positive('have', 'cough?'),
positive('have', 'sore throat?'),
positive('have', 'runny or stuffy nose?'),
positive('have', 'muscle or body aches?'),
positive('have', 'headaches?'),
positive('have', 'fatigue?').
is_disease('Common Cold') :-
positive('have', 'runny or stuffy nose?'),
positive('have', 'sore throat?'),
positive('have', 'headaches?').
is_disease('Pneumonia') :-
positive('have', 'fever and chills'),
positive('have', 'cough?'),
positive('have', 'rappid breathing or difficulty breathing?'),
positive('have', 'chest pain?').
is_disease('Menigitis') :-
positive('have', 'stiff neck?'),
positive('have', 'fever?'),
positive('have', 'headache?'),
positive('have', 'photophobia (eyes being more sensitive to light)?'),
positive('have', 'confusion?').
end implement diagnoseRun