简体   繁体   English

Java中JESS的输出

[英]Output of JESS in Java

I want to send a "fact" to a JESS file within java and get the results back. 我想将一个“事实”发送到java中的JESS文件并返回结果。 I basicly batch the JESS file and then send my data (structure in here) into the engine by .add(). 我基本上批处理JESS文件,然后通过.add()将我的数据(这里的结构)发送到引擎。 I tried to get the JESS results, which should be a string, into a "Value". 我试图将JESS结果(应该是一个字符串)转换为“值”。

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. 我已经在一个简单的java项目中完成了它,而AAA正在返回字符串,但是这里它不起作用。

The (run) function returns the number of rules fired; (run)函数返回触发的规则数; 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. 在Java中获得结果取决于您期望的副作用。 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 . 这可能意味着从收集打印到屏幕的输出在工作内存中查找新创建的事实 ,或让Jess程序调用影响外部世界的Java方法 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; 在没有看到file.clp的内容的file.clp我无法说出你期望的内容,但所有列出的内容都包含在Jess手册中; the phrases above are links to the appropriate sections. 上面的短语是相应部分的链接。 I'm happy to answer any followup questions you might have. 我很乐意回答您可能遇到的任何后续问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM