나는 모든 환자의 증상을 계산하여 그 질병의 확실성을 계산하려고하는데, 나는 각 질병의 증상 하나를 얻고 있습니다.
결과도 일부 중복됩니다.
이프롤로그 - 모든 환자의 증상을 조사하십시오.
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('%').
사람이 제발 도와 드릴까요 :
확실성 요인은 환자의 증상의 수/질병의 증상의 총인가?
감사합니다! 집계를 사용했지만 여전히 필요한 결과를 얻지 못하고 있습니다. 환자가 가지고있는 모든 증상의 수를 각 질병에 대한 데이터베이스의 증상과 함께 알아야합니다. 나는 내가 뭘 잘못하고 있는지 모르겠다. –
@ Ítala : 좋은 조언을 원한다면 새로운 시도로 질문을 편집하십시오! : d – m09
@chac 감사합니다! 그게 내가 정확히 필요한거야 :) –