The following code (see below) behaves in different ways in Jess 7.1 depending on whether a piece of code (that is never called) is present or not.
Comment and uncomment the defquery getClasses to see different results.

1. What is the reason for this behaviour? Is it because the order in which the defQuery getSlotValue gets called in relation to firing of the rule
obtained-beforehand gets changed by the addition of the defquery getClasses?

2. Is there some recommended way to get rid of such problems? Or is the recommended way not to use run-query* in the LHS of rules?


Thanks,

Kartha


=================================================





(deftemplate triple "Template representing a triple"
(slot predicate (default ""))
(slot subject   (default ""))
(slot object    (default ""))
)


;Commenting and uncommenting the getClasses makes
;the behavior different
(defquery getClasses
   "Gets all the classes in memory."
   (triple
       (predicate "rdf:type")
       (object "owl:class")
       (subject ?sub)))

;
(defquery getSlotValue
   "Get the slot value corresponding to slot-name"
   (declare (variables ?resource-name ?slot-name))
   (triple
       (predicate ?slot-name)
       (subject ?resource-name)
       (object ?ob)
       )
   )



(deffunction preauthorized-type (?instance)
   (printout t " In preauthorized-type" crlf)
   (printout t "instance is = " ?instance crlf)
   (bind ?it  (run-query* getSlotValue ?instance "rdf:type"))
   (printout t "it = "?it crlf)
   (printout t " ************" crlf)
   (while (?it next)
(printout t " resource = "(?it getString resource-name) " slot = " (?it getString slot-name)
               ", object =  " (?it getString ob) crlf))
   )






(defrule obtained-beforehand
   (triple
       (predicate "rdf:type")
       (subject ?instance) (object ?))
   (test (preauthorized-type ?instance))
   =>
   (assert (start-processing ?instance))
   )

(deffunction watch-all()
   (watch rules)
   (watch activations)
   (watch facts)
   (watch focus)
   )

(reset)
(watch-all)
(assert (triple (predicate "rdf:type") (subject "zool:elephant") (object "zool:Pachyderm")))
(run)
(facts *)
(assert (triple (predicate "rdf:type") (subject "zool:elephant") (object "zool:Mammal")))
(run)
(facts *)
(assert (triple (predicate "rdf:type") (subject "zool:whale") (object "zool:Mammal")))
(run)
(facts *)
(assert (triple (predicate "rdf:type") (subject "zool:whale") (object "zool:Seacreature")))
(run)
(facts *)



--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [email protected]'
in the BODY of a message to [email protected], NOT to the list
(use your own address!) List problems? Notify [email protected].
--------------------------------------------------------------------

Reply via email to