added comments; made disease database more readable

This commit is contained in:
Jakub R 2021-06-13 22:55:28 +02:00
parent 56a365d9be
commit a172200dc7
1 changed files with 177 additions and 12 deletions

View File

@ -1,25 +1,190 @@
% Ten program ekspercki ma za zadanie pomoc ustalic jakie choroby moga dolegac pacjentowi.
% Choroby posiadaja objawy obowiazkowe i objawy nieobowiazkowe.
% Program jest w stanie rozpoznawac choroby w dwoch stopniach pewnosci.
% Jesli pacjent ma wszystkie obowiazkowe objawy dla choroby (wyzszy stopien pewnosci) sa to
% program wypisze:
% "The patients disease is almost certainly NAZWA_CHOROBY.".
% Jesli pacjent ma przynajmniej jeden (lecz nie wszystkie obowiazkowe) objaw z danej
% choroby (nizszy stopien pewnosci) to zostanie ona tak wypisana:
% "The patients disease might be NAZWA_CHOROBY.".
% Program moze listowac wiele chorob naraz jesli podane objawy pasuja do wiecej niz jednej
% choroby.
% Choroby dla ktorych nie pasuje (nie istnieje w obowiazkowych ani opcjonalnych objawach)
% przynajmniej jeden z podanych przez uzytkownika objawow nie zostana wylistowane.
% Glowna procedura jest: diagnose(Sentences, Answer).
% Jesli wiecej niz jedna choroba pasuje do podanych objawow to mozna podgladac kolejne
% wciskajac klawisz ";".
% Zdania jakie mozna tworzyc to:
% Patient has OBJAW1, OBJAW2, etc. (np. runny nose, spleen enlargment)
% Patients MIEJSCE_BOLU1, MIEJSCE_BOLU2, etc hurts. [hurts, nie hurt!] (np. throat, head)
% Patient OBJAW1, OBJAW2, etc. (np. coughs, faints)
% Patients temperature is CZ_CALKOWITA,CZ_DZIESIETNA. (np. 36,6) [przecinek obowiazkowo miedzy czesc calkowita i dziesietna!]
% Patients erythrocyte level is CZ_CALKOWITA,CZ_DZIESIETNA. (np. 5,5) [przecinek obowiazkowo miedzy czesc calkowita i dziesietna!]
% Wszystkie zdania koncza sie kropka. Mozna zapisac wiele zdan na raz w taki sposob:
% diagnose("Zdanie1 Zdanie2 Zdanie3", Answer).
% np:
% diagnose( "Patient has general weakness, chills. Patients throat hurts. Patients temperature is 39,0. Patients erythrocyte level is 5,0.", Answer).
% Istnieja trzy poziomy goraczki - (-INF ; 37,0]: 0, (37,0 ; 38,0]: 1, (38,0 ; INF): 2.
% Poziom erytrocytow we krwii rowniez jest pogrupowany w poziomy -
% (-INF ; 4,2]: 0, (4,2 ; 5,4]: 1, (5,4 ; INF): 2.
% Choroby wraz z nazwa, objawami obowiazkowymi (pierwsza lista) i opcjonalnymi (druga lista) sa ponizej.
% | ======================= |
% | == disease data base == |
% | ======================= |
disease("flu",[("pain",["throat"]),("runny nose"),("fever",-1),("general weakness"),("coughs")],[("pain",["muscles"]),("erythrocyte",-1),("erythrocyte",0),("erythrocyte",1)]).
disease("malaria",[("fever",2),("general weakness")],[("pain",["head"]),("chills"),("erythrocyte",-1)]).
disease("angina",[("fever",2),("coughs"),("general weakness"),("magnifying lymph nodes"),("pain",["throat"])],[("cannot swallow"),("pain",["head"]),("chills"),("erythrocyte",-1),("erythrocyte",0),("erythrocyte",1)]).
disease("diphtheria",[("fever",1),("general weakness"),("dyspnea")],[("Unclear Speech"),("cannot swallow"),("erythrocyte",-1),("erythrocyte",0),("erythrocyte",1)]).
disease("typhoid",[("fever",0),("pain",["stomach"]),("spleen enlargement")],["tire symptoms",("erythrocyte",-1),("erythrocyte",0),("erythrocyte",1)]).
disease("plague",[("fever",2),("general weakness"),("magnifying lymph nodes"),("liver enlargement"),("spleen enlargement")],[("cloded rash"),("erythrocyte",-1),("erythrocyte",0),("erythrocyte",1)]).
disease("haemophilia",[("epistaxis"),("impaired blood clotting"),("spleen enlargement")],[("fever",0),("fever",1),("fever",2),("erythrocyte",-1),("erythrocyte",0),("erythrocyte",1)]).
disease("whooping cough",[("fever",1),("pain",["throat"]),("paroxysmal cough")],[("conjunctivitis"),("vomits"),("erythrocyte",-1),("erythrocyte",0),("erythrocyte",1)]).
disease("myasthenia",[("excessive fatigue")],[("muscle weakness"),("double vision"),("fever",0),("fever",1),("fever",2),("erythrocyte",-1),("erythrocyte",0),("erythrocyte",1)]).
disease("atrial fibrillation",[("dizziness"),("faints"),("excessive fatigue")],[("coughs"),("fever",0),("fever",1),("fever",2),("erythrocyte",-1),("erythrocyte",0),("erythrocyte",1)]).
disease(
"flu",
[
("pain",["throat"]),
("runny nose"),
("general weakness"),
("coughs")
],
[
("pain",["muscles"]),
("fever",0), ("fever",1), ("fever",2),
("erythrocyte",-1), ("erythrocyte",0), ("erythrocyte",1)
]
).
disease(
"malaria",
[
("fever",2),
("general weakness")
],
[
("pain",["head"]),
("chills"),
("erythrocyte",-1)
]
).
disease(
"angina",
[
("fever",2),
("coughs"),
("general weakness"),
("magnifying lymph nodes"),
("pain",["throat"])
],
[
("cannot swallow"),
("pain",["head"]),
("chills"),
("erythrocyte",-1), ("erythrocyte",0), ("erythrocyte",1)
]
).
disease(
"diphtheria",
[
("fever",1),
("general weakness"),
("dyspnea")
],
[
("unclear speech"),
("cannot swallow"),
("erythrocyte",-1), ("erythrocyte",0), ("erythrocyte",1)
]
).
disease(
"typhoid",
[
("fever",0),
("pain",["stomach"]),
("spleen enlargement")
],
[
"tire symptoms",
("erythrocyte",-1), ("erythrocyte",0), ("erythrocyte",1)
]
).
disease(
"plague",
[
("fever",2),
("general weakness"),
("magnifying lymph nodes"),
("liver enlargement"),
("spleen enlargement")
],
[
("cloded rash"),
("erythrocyte",-1), ("erythrocyte",0), ("erythrocyte",1)
]
).
disease(
"haemophilia",
[
("epistaxis"),
("impaired blood clotting"),
("spleen enlargement")
],
[
("fever",0), ("fever",1), ("fever",2),
("erythrocyte",-1), ("erythrocyte",0), ("erythrocyte",1)
]
).
disease(
"whooping cough",
[
("fever",1),
("pain",["throat"]),
("paroxysmal cough")
],
[
("conjunctivitis"),
("vomits"),
("erythrocyte",-1), ("erythrocyte",0), ("erythrocyte",1)
]
).
disease(
"myasthenia",
[
("excessive fatigue")
],
[
("muscle weakness"),
("double vision"),
("fever",0), ("fever",1), ("fever",2),
("erythrocyte",-1), ("erythrocyte",0), ("erythrocyte",1)
]
).
disease(
"atrial fibrillation",
[
("dizziness"),
("faints"),
("excessive fatigue")
],
[
("coughs"),
("fever",0), ("fever",1), ("fever",2),
("erythrocyte",-1), ("erythrocyte",0), ("erythrocyte",1)
]
).
% | ===================== |
% | == main procedures == |
% | ===================== |
diagnose(Sentence, Answer) :-
interpret(Sentence, Symptoms),
diagnose(Sentences, Answer) :-
interpret(Sentences, Symptoms),
suggest(Symptoms, Answer).