You have to determine the class of a ConditionalElement (this is an
interface for things common to Pattern, Group and Accumulate. If it is a
Pattern, you proceed by iterating over the tests, either thos in a
particular slot or over all.
Add this after your println:
if( e instanceof Pattern ){
Pattern p = (Pattern)e;
Iterator<?> titer = p.getTests( );
while( titer.hasNext() ){
Object o = titer.next();
System.out.println( "test: " + o.toString() );
}
}
On 6/25/08, benders <[EMAIL PROTECTED]> wrote:
>
>
> Hi,
>
> I am trying to parse this .clp file from the documentation.
>
> (deftemplate person (slot firstname) (slot lastname) (slot age))
>
> (defrule welcome-toddlers
> "Give a special greeting to young children"
> (person {age < 3})
> =>
> (printout t "Hello, little one!" crlf))
>
> Here my Code:
> public static void main(String[] args) throws FileNotFoundException,
> IOException, JessException {
> Rete engine = new Rete();
> FileReader file = new FileReader("M:/ikor/myrules.txt");
> Context context = engine.getGlobalContext();
> try {
> Jesp parser = new Jesp(file, engine);
> Object result = Funcall.TRUE;
> while (!result.equals(Funcall.EOF)) {
> result = parser.parseExpression(context, false);
> if (result instanceof Defrule) {
> Defrule rule = (Defrule) result;
> ConditionalElement ce = rule.getConditionalElements();
> int gs = ce.getGroupSize();
> for (int j=0;j<gs;j++) {
> ConditionalElement e = ce.getConditionalElement(j);
> System.out.println(e.toString());
> }
> }
> }
> } finally {
> file.close();
> }
> }
>
> I only get "Main:: person" .
>
> How can I get {age < 3} ?
>
> Thanks a lot
>
> Bernd Enders
>
>
> --
> View this message in context:
> http://www.nabble.com/How-to-parse-the-Conditions---tp18109883p18109883.html
> Sent from the Jess mailing list archive at Nabble.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]
> --------------------------------------------------------------------
>
>