Re: JESS: [EXTERNAL] Dynamic rule-base analysis
"Przemyslaw Woznowski" <[email protected]> Fri, 16 Aug 2013 17:01:40 +0100
| Newsgroups | gmane.comp.java.jess |
|---|---|
| Message-ID | <CA+MrVi8EO+ZSZ8+ACywsU-sSAhMZefe4UEPF5gZb2CGYsoY_Gw@mail.gmail.com> |
--047d7bacc154cb363c04e412b4a4 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=iso-8859-1 Thanks Wolfgang, this helps a lot! I must have missed the getConditionalElements in the API. The analysis of the rule's LHS is working great and it's RHS is more complex but do-able. Once again, thanks for the advice, Pete On Thu, Aug 15, 2013 at 6:51 PM, Wolfgang Laun <[email protected]>wrote: > Rete has listDefrules and Defrule has getConditionalElements, which > lets you retrieve its constituents, depending on it being a Pattern or > Accumulate; if it is a Group you must recurse down... It's like > walking an AST > > RHS is similar. But note that fact modifications are possible in > functions, so if one of these is called on the RHS, you'll have to > investigate in depth. > > Expect to have some fun ;-) > > Cheers > Wolfgang > > > On 14/08/2013, Przemyslaw Woznowski <[email protected]> wrote: > > 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 > > > -------------------------------------------------------------------- > 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]. > -------------------------------------------------------------------- > > -- 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 --047d7bacc154cb363c04e412b4a4 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">Thanks Wolfgang, this helps a lot! I must have missed the = getConditionalElements in the API. The analysis of the rule's LHS is wo= rking great and it's RHS is more complex but do-able.<div><br></div><di= v> Once again, thanks for the advice,</div><div>Pete</div></div><div class=3D"= gmail_extra"><br><br><div class=3D"gmail_quote">On Thu, Aug 15, 2013 at 6:5= 1 PM, Wolfgang Laun <span dir=3D"ltr"><<a href=3D"mailto:wolfgang.laun@g= mail.com" target=3D"_blank">[email protected]</a>></span> wrote:<b= r> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex">Rete has listDefrules and Defrule has getCon= ditionalElements, which<br> lets you retrieve its constituents, depending on it being a Pattern or<br> Accumulate; if it is a Group you must recurse down... It's like<br> walking an AST<br> <br> RHS is similar. But note that fact modifications are possible in<br> functions, so if one of these is called on the RHS, you'll have to<br> investigate in depth.<br> <br> Expect to have some fun ;-)<br> <br> Cheers<br> Wolfgang<br> <div><div class=3D"h5"><br> <br> On 14/08/2013, Przemyslaw Woznowski <<a href=3D"mailto:P.R.Woznowski@cs.= cf.ac.uk">[email protected]</a>> wrote:<br> > Dear Jess users.<br> ><br> > What I am trying to do is to dynamically list all the defrules togethe= r<br> > with their LHS and RHS facts excluding any conditions. Basically what = I<br> > mean is that, for example, if there are Person and Car facts on the ru= le's<br> > LHS and the rule asserts an Owner fact, deletes the Car fact and modif= ies<br> > the Person fact. I would like to create a data structure that would, f= or<br> > each rule, carry it's name and the facts it needs to fire (excludi= ng any<br> > conditions just deftemplate's name) and any deftemplates that appe= ar on the<br> > rule's RHS. So for the example above, something like:<br> > Rule_1<br> > =A0needs: Person, Car<br> > =A0asserts: Owner<br> > =A0modifies: Person<br> > =A0deletes: Car<br> ><br> > I can get a list of all defrules via the listDefrules() method called = on<br> > the Rete object but then it gets tricky. The listNodes() method called= on<br> > the HasLHS object gives a textual description of the rule's LHS bu= t I<br> > cannot find a method that would simply return name of facts on the LHS= .<br> > Some text processing would solve the rule's LHS problem as I can l= ook for<br> > occurrences of "::" to find facts. However, the rule's R= HS is more<br> > problematic as I cannot find a method that would give me what I want.<= br> ><br> > I would appreciate your help with this one.<br> ><br> > Best regards,<br> > Pete<br> ><br> > --<br> > Przemyslaw (Pete) Woznowski, PhD candidate & RA<br> > Email: <a href=3D"mailto:[email protected]">P.R.Woznowski= @cs.cardiff.ac.uk</a><br> > Room C/2.06, Desk 8<br> > Cardiff School of Computer Science & Informatics,<br> > Cardiff University,<br> > Queen's Buildings,<br> > 5 The Parade, Roath,<br> > Cardiff, CF24 3AA, UK<br> > & School of Healthcare Studies,<br> > Cardiff University<br> > Cardigan House<br> > Heath Park Campus<br> > Cardiff, CF14 4XN, UK<br> ><br> </div></div>---------------------------------------------------------------= -----<br> To unsubscribe, send the words 'unsubscribe jess-users <a href=3D"mailt= o:[email protected]">[email protected]</a>'<br> in the BODY of a message to <a href=3D"mailto:[email protected]">majordo= [email protected]</a>, NOT to the list<br> (use your own address!) List problems? Notify <a href=3D"mailto:owner-jess-= [email protected]">[email protected]</a>.<br> --------------------------------------------------------------------<br> <br> </blockquote></div><br><br clear=3D"all"><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.Woznowski@= cs.cardiff.ac.uk</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> --047d7bacc154cb363c04e412b4a4--