2
我试图计算所有患者的症状来计算疾病的确定性因素,但我只是得到每种疾病的一种症状。
此外,结果显示了一些重复。
的可信度/患者的症状的人数占总数的疾病的症状:
Prolog - 计算所有患者的症状
start:-
write('Enter the name of the patient: '), read(Patient),
write('Enter the symptoms: '), read(Symptoms), write('\n'),
countSint(Diseases, Symptoms , Patient).
countSint(Diseases, Symptoms , Patient) :-
findall(Sint , member(Sint, Symptoms), L1), length(L1 , Size),
( Size < 2
-> writeln('Enter with at least 3 symptoms...\n'), start
; Size > 1
-> write('\n Enter semicolon...:\n\n'), write('Patient: '), write(Patient),
diagnose(Symptoms,Diseases, L)
).
diagnose(Symptoms,Diseases,L) :- search(Symptoms, Diseases, L).
% disease(Disease, Symptoms, Num).
disease(meningitis,[fever, stiff_neck],2).
disease(dengue,[fever, vomiting, red_spots], 3).
% search(Symptoms, Diseases, L).
search([H|T] , Diseases, L) :-
disease(Disease, Symptoms, Num),
Disease0 = [Disease,Diseases],
member(H, Symptoms),
search(T , Diseases0, L),
write('has '), write(Disease), writeln(': '),
setof(H, (disease(Disease, Symptoms, Num),
member(H, Symptoms)), L),
length(L, Size),
calc_cf(Num, Size, R).
calc_cf(Num, Size, R):- % Calculate the certainty factor
R is Size/Num * 100,
write('The certainty factor is '),
write(R),
writeln('%').
谁能帮助我,好吗?
谢谢回答,CHAC! 我用聚合,但我仍然没有得到我需要的结果。我需要获取患者与我的数据库中每种疾病症状相同的所有症状的数量。我不知道我做错了什么。 –
@Ítala:编辑你的问题与你的新尝试,如果你想好的建议! :d – m09
@chac谢谢!这正是我需要:) –