I have the code below in Prolog and I made a GUI in Java.
In this gui I have some checkboxes with symptoms and I want to pass only clicked symptoms in the list of findDiseases predicate. Can anyone tell me how I can do that? The only thing that I know is how to call start predicate..
start:-
findDiseases([headache,weakness,heartbeat], Diseases),
one_occurrence(Diseases, DiseasesNoDup),
write(DiseasesNoDup).
findDiseases(PositiveSymptoms, Diseases) :-
findDiseases(PositiveSymptoms, Diseases, []).
findDiseases([], Answer, Answer).
findDiseases([H|T], Diseases, Answer) :-
findall(
Disease,
(
kb(Disease,Simptoms_list,Feauture_list),
(member(H,Simptoms_list);member(H,Feauture_list))
),
As),
append(As, Answer, NewAnswer),
findDiseases(T, Diseases, NewAnswer).
% kb(diagnosis,symptoms_list,features_list).
kb(iron_defficiency,
[headache, dizziness, cold, weakness, fatigue, heartbeat, loose_concentration, swelling_tongue, breath],
[gender, pregnancy, vitamin_poor_diet, fe, feritin, b12, hb, hct, mcv, plt, wbc, rtc]
).
kb(thalassemia,
[loose_appetite, painful_spleen, pale_skin],
[gender, pregnancy, parent1, parent2, face_features, fe, feritin, b12, hb, hct, mcv, plt, wbc, hbf, hba1, hba2, rtc]
).
kb(minor_thalassemia,
[headache, fatigue, weakness, pale_skin, swelling_tongue, cold, heartbeat, loose_concentration, breath, dizziness],
[vitamin_poor_diet, gender, pregnancy, parent1, parent2, hbaf, hba2, fe, feritin, b12, hb, hct, mcv, plt, wbc, rtc]
).
kb(drepanocytocis,
[headache, weakness, fatigue, pale_skin, swelling_tongue, cold, loose_concentration, breath, dizziness, heartbeat, ulcers, painful_spleen, pain_in_extrimity],
[gender, pregnancy, vitamin_poor_diet, shape_rbc, hbs, hbf, fe, feritin, b12, hb, hct, mcv, plt, wbc, rtc]
).
yposynolo([X],[X]).
yposynolo([H|Tail],[X]) :-
(H==X),
yposynolo(Tail,[X]).
yposynolo([X],[H|Tail]) :- member(X,[H|Tail]).
yposynolo([H1|Tail1],[H2|Tail2]) :-
member(H1,[H2|Tail2]),
yposynolo(Tail1,[H2|Tail2]).
same_elements(List1,List2) :-
yposynolo(List1,List2),
yposynolo(List2,List1).
unique_appearance([X]).
unique_appearance([H|Tail]) :-
(\+member(H,Tail)),
unique_appearance(Tail).
one_occurrence([H1|Tail1],[H2|Tail2]) :-
same_elements([H1|Tail1],[H2|Tail2]),
unique_appearance([H2|Tail2]).