Output of JESS in Java

十年热恋 提交于 2019-12-19 09:44:46

问题


I want to send a "fact" to a JESS file within java and get the results back. I basicly batch the JESS file and then send my data (structure in here) into the engine by .add(). I tried to get the JESS results, which should be a string, into a "Value".

Rete engine = new Rete();
engine.batch("file.clp");
Value = AAAnull;
try{
   engine.add(structure)
   AAA = engine.eval("(run)");
   } catch ...

System.out.println(AAA);

The result is always a number, although the result should be a string. I have worked it out in a simple java project and the AAA is returning the string, but here it is not working.


回答1:


The (run) function returns the number of rules fired; that's the number you're seeing here.

The real results of running your program are the side effects it causes; getting the result in Java depends on what side effects you're expecting. That may mean anything from collecting output printed to the screen, finding newly created facts in working memory, or having your Jess program call Java methods that effect the outside world. Without seeing the contents of file.clp I can't say what you're expecting, but all of these things listed are covered in the Jess manual; the phrases above are links to the appropriate sections. I'm happy to answer any followup questions you might have.



来源:https://stackoverflow.com/questions/16048528/output-of-jess-in-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!