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&#39;s LHS is wo=
rking great and it&#39;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">&lt;<a href=3D"mailto:wolfgang.laun@g=
mail.com" target=3D"_blank">[email protected]</a>&gt;</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&#39;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&#39;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 &lt;<a href=3D"mailto:P.R.Woznowski@cs.=
cf.ac.uk">[email protected]</a>&gt; wrote:<br>
&gt; Dear Jess users.<br>
&gt;<br>
&gt; What I am trying to do is to dynamically list all the defrules togethe=
r<br>
&gt; with their LHS and RHS facts excluding any conditions. Basically what =
I<br>
&gt; mean is that, for example, if there are Person and Car facts on the ru=
le&#39;s<br>
&gt; LHS and the rule asserts an Owner fact, deletes the Car fact and modif=
ies<br>
&gt; the Person fact. I would like to create a data structure that would, f=
or<br>
&gt; each rule, carry it&#39;s name and the facts it needs to fire (excludi=
ng any<br>
&gt; conditions just deftemplate&#39;s name) and any deftemplates that appe=
ar on the<br>
&gt; rule&#39;s RHS. So for the example above, something like:<br>
&gt; Rule_1<br>
&gt; =A0needs: Person, Car<br>
&gt; =A0asserts: Owner<br>
&gt; =A0modifies: Person<br>
&gt; =A0deletes: Car<br>
&gt;<br>
&gt; I can get a list of all defrules via the listDefrules() method called =
on<br>
&gt; the Rete object but then it gets tricky. The listNodes() method called=
 on<br>
&gt; the HasLHS object gives a textual description of the rule&#39;s LHS bu=
t I<br>
&gt; cannot find a method that would simply return name of facts on the LHS=
.<br>
&gt; Some text processing would solve the rule&#39;s LHS problem as I can l=
ook for<br>
&gt; occurrences of &quot;::&quot; to find facts. However, the rule&#39;s R=
HS is more<br>
&gt; problematic as I cannot find a method that would give me what I want.<=
br>
&gt;<br>
&gt; I would appreciate your help with this one.<br>
&gt;<br>
&gt; Best regards,<br>
&gt; Pete<br>
&gt;<br>
&gt; --<br>
&gt; Przemyslaw (Pete) Woznowski, PhD candidate &amp; RA<br>
&gt; Email: <a href=3D"mailto:[email protected]">P.R.Woznowski=
@cs.cardiff.ac.uk</a><br>
&gt; Room C/2.06, Desk 8<br>
&gt; Cardiff School of Computer Science &amp; Informatics,<br>
&gt; Cardiff University,<br>
&gt; Queen&#39;s Buildings,<br>
&gt; 5 The Parade, Roath,<br>
&gt; Cardiff, CF24 3AA, UK<br>
&gt; &amp; School of Healthcare Studies,<br>
&gt; Cardiff University<br>
&gt; Cardigan House<br>
&gt; Heath Park Campus<br>
&gt; Cardiff, CF14 4XN, UK<br>
&gt;<br>
</div></div>---------------------------------------------------------------=
-----<br>
To unsubscribe, send the words &#39;unsubscribe jess-users <a href=3D"mailt=
o:[email protected]">[email protected]</a>&#39;<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 &amp; 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 &amp; Informatics=
,=A0<div>Cardiff University, <br>Queen&#39;s Buildings, <br>5 The Parade, R=
oath,<br>Cardiff, CF24 3AA, UK</div><div>&amp; 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--