JESS: [EXTERNAL] Dynamic rule-base analysis
"Przemyslaw Woznowski" <[email protected]> Wed, 14 Aug 2013 13:43:52 +0100
| Newsgroups | gmane.comp.java.jess |
|---|---|
| Message-ID | <CA+MrVi8-W9fhQKMfMfaREEehxSnGLKP2L=mdZPxz++G8wWX=AQ@mail.gmail.com> |
--e89a8f647861bb91c904e3e7b561 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=iso-8859-1 Dear Jess users. What I am trying to do is to dynamically list all the defrules together with their LHS and RHS facts excluding any conditions. Basically what I mean is that, for example, if there are Person and Car facts on the rule's LHS and the rule asserts an Owner fact, deletes the Car fact and modifies the Person fact. I would like to create a data structure that would, for each rule, carry it's name and the facts it needs to fire (excluding any conditions just deftemplate's name) and any deftemplates that appear on the rule's RHS. So for the example above, something like: Rule_1 needs: Person, Car asserts: Owner modifies: Person deletes: Car I can get a list of all defrules via the listDefrules() method called on the Rete object but then it gets tricky. The listNodes() method called on the HasLHS object gives a textual description of the rule's LHS but I cannot find a method that would simply return name of facts on the LHS. Some text processing would solve the rule's LHS problem as I can look for occurrences of "::" to find facts. However, the rule's RHS is more problematic as I cannot find a method that would give me what I want. I would appreciate your help with this one. Best regards, Pete -- Przemyslaw (Pete) Woznowski, PhD candidate & RA Email: [email protected] Room C/2.06, Desk 8 Cardiff School of Computer Science & Informatics, Cardiff University, Queen's Buildings, 5 The Parade, Roath, Cardiff, CF24 3AA, UK & School of Healthcare Studies, Cardiff University Cardigan House Heath Park Campus Cardiff, CF14 4XN, UK --e89a8f647861bb91c904e3e7b561 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">Dear Jess users.<div><br></div><div>What I am trying to do= is to dynamically list all the defrules together with their LHS and RHS fa= cts excluding any conditions. Basically what I mean is that, for example, i= f there are Person and Car facts on the rule's LHS and the rule asserts= an Owner fact, deletes the Car fact and modifies the Person fact. I would = like to create a data structure that would, for each rule, carry it's n= ame and the facts it needs to fire (excluding any conditions just deftempla= te's name) and any deftemplates that appear on the rule's RHS. So f= or the example above, something like:</div> <div>Rule_1</div><div>=A0needs: Person, Car</div><div>=A0asserts: Owner</di= v><div>=A0modifies: Person</div><div>=A0deletes: Car</div><div><div><br></d= iv><div>I can get a list of all defrules via the listDefrules() method call= ed on the Rete object but then it gets tricky. The listNodes() method calle= d on the HasLHS object gives a textual description of the rule's LHS bu= t I cannot find a method that would simply return name of facts on the LHS.= Some text processing would solve the rule's LHS problem as I can look = for occurrences of "::" to find facts. However, the rule's RH= S is more problematic as I cannot find a method that would give me what I w= ant.</div> <div><br></div><div>I would appreciate your help with this one.</div><div><= br></div><div>Best regards,</div><div>Pete</div><div><br></div>-- <br><div = dir=3D"ltr">Przemyslaw (Pete) Woznowski, PhD candidate & RA<br>Email: <= a href=3D"mailto:[email protected]" target=3D"_blank">P.R.Wozn= [email protected]</a><br> Room C/2.06, Desk 8<br>Cardiff School of Computer Science & Informatics= ,=A0<div>Cardiff University, <br>Queen's Buildings, <br>5 The Parade, R= oath,<br>Cardiff, CF24 3AA, UK</div><div>& School of Healthcare Studies= ,</div> <div><span style=3D"background-color:rgb(255,255,255)"><span style=3D"font-= family:Verdana,Geneva,Arial,Helvetica,sans-serif;line-height:15.31666660308= 8379px">Cardiff University</span><br style=3D"font-family:Verdana,Geneva,Ar= ial,Helvetica,sans-serif;line-height:15.316666603088379px"> <span style=3D"font-family:Verdana,Geneva,Arial,Helvetica,sans-serif;line-h= eight:15.316666603088379px">Cardigan House</span><br style=3D"font-family:V= erdana,Geneva,Arial,Helvetica,sans-serif;line-height:15.316666603088379px"> <span style=3D"font-family:Verdana,Geneva,Arial,Helvetica,sans-serif;line-h= eight:15.316666603088379px">Heath Park Campus</span><br style=3D"font-famil= y:Verdana,Geneva,Arial,Helvetica,sans-serif;line-height:15.316666603088379p= x"> <span style=3D"font-family:Verdana,Geneva,Arial,Helvetica,sans-serif;line-h= eight:15.316666603088379px">Cardiff,=A0</span><span style=3D"font-family:Ve= rdana,Geneva,Arial,Helvetica,sans-serif;line-height:15.316666603088379px">C= F14 4XN, UK</span></span></div> </div> </div></div> --e89a8f647861bb91c904e3e7b561--