On Feb 24, 2010, at 12:12 AM, Manolis Mavrikis wrote:
So let's say I would like to write a rule that check whether the
value of MockVerifier is true (but for other reasons I don't want to
add MockVerifier as a fact). So I have a fact like this
==> f-4 (MAIN::analysisResultUpdater (class <Java-
Object:java.lang.Class>)
(testMe TRUE)
(verifier <Java-
Object:uk.ac.lkl.migen.system.AI.analysis.MockVerifier>)
(OBJECT <Java-
Object:uk.ac.lkl.migen.system.AI.reasoning.AnalysisResultUpdater>))
My latest attempt is something like
(defrule MOCK_VERIFIER_TRUE
(analysisResultUpdater (verifier ?aru1))
(MockVerifier (value ?value) (OBJECT ?aru1))
;;and here I was thinking that maybe I should use test but
=>
To continue the database analogy: not adding the MockVerifiers to
working memory is like not having a MockVerifiers table, but instead
having some structured text in a column named "MockVerifiers" in the
AnalysisResultUpdater table. So to ask this sort of question in that
database, you'd select AnalysisResultUpdaters, then use a LIKE clause
or some kind of text functions to match the MockVerifier column. I
like the database analogy because it makes it clear that you should
expect this to be less elegant and less performant than having a
separate table. But you could write the rule in Jess something like
this using a predicate constraint:
(defrule MOCK_VERIFIER_TRUE
(analysisResultUpdater (verifier ?aru1&:(eq (?aru1 getValue) TRUE))))
=>
I deliberately wrote this in a general way that would work for non-
boolean properties as well. For booleans you can actually remove the
redundant comparison function:
(defrule MOCK_VERIFIER_TRUE
(analysisResultUpdater (verifier ?aru1&:(?aru1 getValue)))
=>
---------------------------------------------------------
Ernest Friedman-Hill
Informatics & Decision Sciences Phone: (925) 294-2154
Sandia National Labs
PO Box 969, MS 9012 [email protected]
Livermore, CA 94550 http://www.jessrules.com
--------------------------------------------------------------------
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].
--------------------------------------------------------------------