JESS: query distinct values of a slot
Hello, I need some help with queries. How can I query the distinct values of a slot? The manual explains how to select facts with a concrete value in an slot. But my problem is different, for example, with these facts: *Jess> *(deffacts data (person (firstName Fred) (lastName Smith)(age 12)) (person (firstName Fred) (lastName Jones)(age 9)) (person (firstName Bob)(lastName Thomas) (age 32)) (person (firstName Bob)(lastName Smith)(age 22)) (person (firstName Pete) (lastName Best) (age 21)) (person (firstName Pete) (lastName Smith)(age 44)) (person (firstName George) (lastName Smithson) (age 1)) ) I would like to obtain the distinct values of firstname slot: *Fred Bob Pete George* Is that possible? Thank you in advance Joaquín
RE: JESS: dealing with shadow facts having null properties
When I add a shadow fact with a property having a null value, I get an exception (in updateMultiSlot IRRC). JFL > From: [EMAIL PROTECTED]> Subject: Re: JESS: dealing with shadow facts having > null properties> Date: Thu, 2 Aug 2007 15:57:55 -0400> To: > jess-users@sandia.gov> > Jess has been able to handle null properties for a > long time; 6.1p8 > can handle them, as can the current versions. What problem > are you > having, exactly?> > On Aug 2, 2007, at 2:19 PM, Skeptic 2000 > wrote:> > >> > Hi,> >> > I need to add in the working memory some shadow > facts with > > properties whose values are null. Currently, my workaround is > to > > use a "NullObject" to prevent Jess from crashing upon finding a > > > null value.> >> > Is it the recommended way to do it ?> >> > JFL> >> > Soyez > parmi les premiers à essayer Windows Live Mail.> > > -> Ernest > Friedman-Hill> Advanced Software Research Phone: (925) 294-2154> Sandia > National Labs FAX: (925) 294-2234> 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]> > > _ Soyez parmi les premiers à essayer Windows Live Mail. http://ideas.live.com/programpage.aspx?versionId=5d21c51a-b161-4314-9b0e-4911fb2b2e6d
Re: JESS: How to print the system time
Jess has a "time" function which returns System.currentTime() / 1000. Otherwise, anything you can use in Java, you can use in Jess; for example (printout t ((new java.util.Date) toString) crlf) On Aug 2, 2007, at 3:53 PM, Mrinal Khanvilkar wrote: Hi all, How do i print the current time of the system. In java we can do that using Datetime.Now, but i have no idea how to do it in JESS. is there any way i can do "(printout t TimeAndDate clf)" Thanks, Mrinal - Ernest Friedman-Hill Advanced Software Research Phone: (925) 294-2154 Sandia National LabsFAX: (925) 294-2234 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]
Re: JESS: dealing with shadow facts having null properties
Jess has been able to handle null properties for a long time; 6.1p8 can handle them, as can the current versions. What problem are you having, exactly? On Aug 2, 2007, at 2:19 PM, Skeptic 2000 wrote: Hi, I need to add in the working memory some shadow facts with properties whose values are null. Currently, my workaround is to use a "NullObject" to prevent Jess from crashing upon finding a null value. Is it the recommended way to do it ? JFL Soyez parmi les premiers à essayer Windows Live Mail. - Ernest Friedman-Hill Advanced Software Research Phone: (925) 294-2154 Sandia National LabsFAX: (925) 294-2234 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]
JESS: How to print the system time
Hi all, How do i print the current time of the system. In java we can do that using Datetime.Now, but i have no idea how to do it in JESS. is there any way i can do "(printout t TimeAndDate clf)" Thanks, Mrinal
JESS: dealing with shadow facts having null properties
Hi, I need to add in the working memory some shadow facts with properties whose values are null. Currently, my workaround is to use a "NullObject" to prevent Jess from crashing upon finding a null value.Is it the recommended way to do it ?JFL _ Soyez parmi les premiers à essayer Windows Live Mail. http://ideas.live.com/programpage.aspx?versionId=5d21c51a-b161-4314-9b0e-4911fb2b2e6d
Re: JESS: Redefining extended deftemplates
Hi Howard, Yep, I see why this happens. Thanks. We'll get it straightened out! On Aug 1, 2007, at 1:47 PM, Greenblatt, Howard wrote: Hi there, In our system we sometimes need to reload a rules file that may contain deftemplates. This could happen for example if a rule changes and needs to be redefined in the system. We reload the rules file with the updated rule. Since deftemplates cannot be redefined (without clearing out the rules engine first), we don't allow them to be modified; however they still may be in the file. I have seen the jess src code (jess70p1 - Deftemplate.java – line 155 “equals” method) where you check to see if a new deftemplate object matches an existing one of the same name. If they are identical there is no error. This works fine except where the deftemplate extends another deftemplate. It appears that the parent id of the extended deftemplate is different even though the parent template is identical. This error can be duplicated in a single script. Consider the following: (deftemplate t1 (slot s1)) (deftemplate t2 extends t1 (slot s2)) ; ; redefining t1 is no problem ; (deftemplate t1 (slot s1)) ; ; redefining t2 causes an error where you cannot redefine ; the template even though it is exactly the same. ; (deftemplate t2 extends t1 (slot s2)) I believe what is happening is that when t1 is redefined and added to the m_deftemplates TreeMap (Defmodule,java – line 125 “addDeftemplate” method) it is assigned a new id which does not match the id of t1 (as a parent) when template t2 is redefined. Thanks, - Howard - Ernest Friedman-Hill Advanced Software Research Phone: (925) 294-2154 Sandia National LabsFAX: (925) 294-2234 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]
Re: JESS: Redefining extended deftemplates
Maybe this is a workaround: Assuming that the rules file you reload contains all deftemplates referenced by these rules (or, in other words, if this rules file can be batched into a virgin rete engine), then you could batch the file with the updated rules into an auxiliary Rete, iterate over all rules in the auxiliary and add them to the working Rete. Below is a Userfunction (load-rules ) doing just that. kr Wolfgang package at.laune.jess; import java.util.Iterator; import jess.Context; import jess.HasLHS; import jess.JessException; import jess.Rete; import jess.RU; import jess.Userfunction; import jess.Value; import jess.ValueVector; /** * A Jess Userfunction class (re-)loading rules from a Jess file. * * (load-rules ) * * @author Wolfgang Laun */ public class LoadRules implements Userfunction { private static final String NAME = "load-rules"; /** Get the name of the Jess function. * @see jess.Userfunction#getName() */ public String getName(){ return NAME; } /** Call the userfunction * @see jess.Userfunction#call(jess.ValueVector, jess.Context) */ public Value call( ValueVector vv, Context context ) throws JessException { int narg = vv.size() - 1; // Check that we have no element. if( narg != 1 ) throw new JessException( NAME, "missing argument:", "pathname"); Rete theRete = context.getEngine(); String path = vv.get( 1 ).stringValue( context ); Rete aux = new Rete(); aux.batch( path ); // Iterate over all rules and queries. int nRules = 0; Iterator ruleIt = aux.listDefrules(); while( ruleIt.hasNext() ){ HasLHS rq = (HasLHS)ruleIt.next(); theRete.addDefrule( rq ); nRules++; } return new Value( nRules , RU.INTEGER ); } } Greenblatt, Howard wrote: Hi there, In our system we sometimes need to reload a rules file that may contain deftemplates. This could happen for example if a rule changes and needs to be redefined in the system. We reload the rules file with the updated rule. Since deftemplates cannot be redefined (without clearing out the rules engine first), we don't allow them to be modified; however they still may be in the file. I have seen the jess src code (jess70p1 - Deftemplate.java - line 155 "equals" method) where you check to see if a new deftemplate object matches an existing one of the same name. If they are identical there is no error. This works fine except where the deftemplate extends another deftemplate. It appears that the parent id of the extended deftemplate is different even though the parent template is identical. This error can be duplicated in a single script. Consider the following: (deftemplate t1 (slot s1)) (deftemplate t2 extends t1 (slot s2)) ; ; redefining t1 is no problem ; (deftemplate t1 (slot s1)) ; ; redefining t2 causes an error where you cannot redefine ; the template even though it is exactly the same. ; (deftemplate t2 extends t1 (slot s2)) I believe what is happening is that when t1 is redefined and added to the m_deftemplates TreeMap (Defmodule,java - line 125 "addDeftemplate" method) it is assigned a new id which does not match the id of t1 (as a parent) when template t2 is redefined. Thanks, - Howard 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]
JESS: Redefining extended deftemplates
Hi there, In our system we sometimes need to reload a rules file that may contain deftemplates. This could happen for example if a rule changes and needs to be redefined in the system. We reload the rules file with the updated rule. Since deftemplates cannot be redefined (without clearing out the rules engine first), we don't allow them to be modified; however they still may be in the file. I have seen the jess src code (jess70p1 - Deftemplate.java - line 155 "equals" method) where you check to see if a new deftemplate object matches an existing one of the same name. If they are identical there is no error. This works fine except where the deftemplate extends another deftemplate. It appears that the parent id of the extended deftemplate is different even though the parent template is identical. This error can be duplicated in a single script. Consider the following: (deftemplate t1 (slot s1)) (deftemplate t2 extends t1 (slot s2)) ; ; redefining t1 is no problem ; (deftemplate t1 (slot s1)) ; ; redefining t2 causes an error where you cannot redefine ; the template even though it is exactly the same. ; (deftemplate t2 extends t1 (slot s2)) I believe what is happening is that when t1 is redefined and added to the m_deftemplates TreeMap (Defmodule,java - line 125 "addDeftemplate" method) it is assigned a new id which does not match the id of t1 (as a parent) when template t2 is redefined. Thanks, - Howard