Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

diagnostic tool 1

Status
Not open for further replies.

Ade12

Technical User
Oct 26, 2008
2
GB
I am trying to create a very simple symptom diagnostic tool using SWI prolog and i have tried to learn the language but it all seems very confusing. just when i think i'm getting somewhere i go back to square one. I don't know where or how to begin. HELP!!!!
 
i do. or i think i do. Here is my code. what am i doing wrong?

% Definite Clause Grammar and Syntax
sentence --> noun_phrase, verb_phrase.

noun_phrase --> determiner, noun.
noun_phrase --> noun.

verb_phrase --> verb.
verb_phrase --> verb, noun_phrase.

determiner --> [a].
determiner --> [the].
determiner --> [an].
determiner --> [this].
determiner --> [all].
determiner --> [that].
determiner --> [those].
determiner --> [which].
determiner --> [both].
determiner --> [each].
determiner --> [many].
determiner --> [every].
determiner --> [either].
determiner --> [neither].
determiner --> [several].
determiner --> [some].
determiner --> [any].
determiner --> [you].
determiner --> [one].
determiner --> [another].
determiner --> [my].


noun --> [cold].
noun --> [asthma].
noun --> [sickle_cell].
noun --> [runny_nose].

verb --> [have].
verb --> [feel].
verb --> [felt].
verb --> [receive].
verb --> [had].
verb --> [received].
verb --> [take].
verb --> [taken].
verb --> [took].
verb --> [breathe].
verb --> [breathed].
verb --> [breathing].
verb --> [cried].
verb --> [cry].
verb --> [crying].
verb --> [take].

question --> [what].
question --> [why].
question --> [where].
question --> [which].
question --> [who].
question --> [how].
question --> [whose].
question --> [is].
question --> [are].

sentence_terminator('.').
sentence_terminator('?').
sentence_terminator('!').

% SDT knowledge base
if 'red blood cells are sickle shaped'
then 'person is probably a sickler'.

if 'experiencing body pains'
then 'person is probably a sickler'.

% managing questions and answers
question('experiencing body pains','are you experiencing body pains?',
['experiencing happiness'-no],['experiencing happiness'-yes]).

back_chain:-
goal( R ),
chain_demo( R ),
chain_post_result( conclusive(R) ).
chain_post_result( inconclusive ).

% probing
query(Sympt, Value):-
write(Sympt:Value),
write('? '),
read(yes).

% using a cut to stop further probing
query(Sympt, Value):-
known(yes, Sympt, Value), !. % stop further querying if true/yes
query(Sympt, Value):-
known(_, Sympt, Value), % if false fail
!,
fail.

%% database of defects and symptoms
defect(sickle_cell_anaemia):-
symptom(sickle_shaped_red_blood_cells),
symptom(crescent_shaped_red_blood_cells),
symptom(bone_pains),
symptom(chest_pain),
symptom(low_infection_immunity),
symptom(fatigue),
symptom(breathlessness),
symptom(rapid_heart_rate),
symptom(ulcers),
symptom(delayed_growth),
symptom(jaundice),
symptom(joint_pain),
symptom(vomitting),
symptom(dehydration),
symptom(excessive_thirst),
symptom(excessive_penis_pain),
symptom(decreased_fertility),
symptom(sickle_traits_in_parents),
symptom(family_history_of_sickle_cell),
symptom(abdominal_pains),
symptom(blood _type_ss),
symptom(blood _type_sc),
symptom(slim_figure),
symptom(yellow_cornea),
symptom(poor_blood_circulation),
symptom(slow_wound_healing),
symptom(frequent_crisis),
symptom(body_pains),
symptom(hip_degeneration),
symptom(osteoathritis).

defect(cold):-
symptom(cattargh),
symptom(blocked_nose),
symptom(runny_nose),
symptom(pain_when_swallowing),
symptom(sneezing),
symptom(ear_ache),
symptom(tiredness),
symptom(fatigue),
symptom(watery_eyes),
symptom(coughing),
symptom(sore_throat),
symptom(loss_of_appetite),
symptom(fever),
symptom(feeling_cold),
symptom(head_ache).

defect(asthma):-
symptom(shortness_of_breath),
symptom(protruding_eyeballs),
symptom(shortness_of_breath),
symptom(coughing),
symptom(wheezing),
symptom(tightness_in_the_chest).
 
Well, you have a lot of things to do.
These predicates "goal", "chain_demo", "chain_post_result", "known" are not defined.

Are all the symptoms for sickle_cell_anaemia necessary ? or only a combination of some ?

For the beginning, I think that the DCG code is not usefull.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top