我正在使用JessTab API通过Jess规则在Java中操作本体。以类Person为例的简单本体用作示例。我从Java运行以下代码来为Person类声明新实例:
private final Rete r = new Rete();
Random randomGenerator = new Random();
r.executeCommand("(make-instance test of http://www.owl-ontologies.com/Ontology1431767500.owl#Person)");
列出类Person的个体的简单规则如下所示不会显示新声明的实例测试:
(defrule listPeople
(object (is-a http://www.owl-ontologies.com/Ontology1431767500.owl#Person)
(OBJECT ?p)
)
=>
(printout t "Person instances: " (instance-name ?p) crlf)
)
使用JessTab在Protege IDE中执行此操作会显示实例,但从Java NetBeans运行时不会考虑make-instance命令声明的事实。我尝试在执行make-instance命令后保存本体,然后运行规则,但出现相同的行为,即不考虑新事实。我是否必须运行特定的JessTab命令?
答案 0 :(得分:0)
make-instance命令应包含map关键字:
r.executeCommand("(make-instance test of http://www.owl-ontologies.com/Ontology1431767500.owl#Person map)");