Hello -
I have some questions on the functionality and design of a multislot. Sorry if I am long winded on this.
I have the following deftemplate and asserted the facts:
(deftemplate illness (slot name) (multislot symptoms))
f-0 (MAIN::initial-fact)
f-1 (MAIN::illness (name Flu) (symptoms "Runny Nose" "Sore Throat"))
f-2 (MAIN::illness (name Disentery) (symptoms "Abdominal Pain" "Fever"))
f-3 (MAIN::illness (name Diptheria) (symptoms "Fever" "Sore Throat"))
f-4 (MAIN::illness (name Appendicitis) (symptoms "Abdominal Pain" "Loss of Appetite"))
I want to come up with a distinct list of all symptoms. So I created a defquery:
(defquery get-all-symptoms (illness (symptoms $?list)))
And executed it by the following function (with debugging output)
(deffunction get-symptom-list ()
; run query to get all illnesses with related symptoms
(bind ?it (run-query get-all-symptoms))
(while (?it hasNext)
(bind ?token (call ?it next))
(bind ?fact (call ?token fact 1))
(bind $?symptoms (create$(fact-slot-value ?fact symptoms)))
(printout t "Fever is member ? " (member$ "Fever" $?symptoms) crlf)
(printout t "1st element of list " (nth$ 1 $?symptoms) crlf)
)
)
I get the following output:
Fever is member ? FALSE
1st element of list ("Runny Nose" "Sore Throat")
Fever is member ? FALSE
1st element of list ("Abdominal Pain" "Fever")
…..
So to the questions.
1. What am I doing wrong in not being able to isolate the individual items in a multislot?
2. From prior emails on the archive I get the impression I should 'normalize' the data something along the lines of
(deftemplate symptom (slot name)) or just use for example (assert (symptom "Fever"))
(deftemplate illness (slot name) (multislot symptoms))
And then assert facts like:
(bind ?Fever (assert (symptom name("Fever"))) )
(bind ?Abdominal_Pain (assert (symptom (name "Abdominal Pain"))) )
(assert (illness (name "Disentery") (symptoms ?Fever ?Abdominal_Pain)) )
Is the above a better way of assigning the values to a multislot from an efficiency and access point of view?
Thanks
Eric
This e-mail and any files transmitted with it, are confidential to National Grid and are intended solely for the use of the individual or entity to whom they are addressed. If you have received this e-mail in error, please contact the National Grid USA Enterprise Support Center on 508-389-3375 or 315-428-6360.
