我正在尝试使用 SWRLAPI 和 OWLAPI 将 SWRL 规则添加到我的本体中。我正在尝试使用与 SWRLAPI 兼容的 OWLAPI 版本。但是,我在创建规则时仍然遇到错误。这似乎是依赖管理的问题。我正在使用 gradle 作为依赖管理器,所以这应该已经解决了这个问题。
异常(exception)是:
Error creating rule engine Drools. Exception: java.lang.NoClassDefFoundError. Message: org/drools/runtime/rule/AgendaFilter"
我的build.gradle依赖文件:
dependencies {
compile group: 'net.sourceforge.owlapi', name: 'owlapi-distribution', version: '4.1.3'
compile group: 'net.sourceforge.owlapi', name: 'org.semanticweb.hermit', version: '1.4.1.513'
compile 'edu.stanford.swrl:swrlapi:2.0.5'
compile 'edu.stanford.swrl:swrlapi-drools-engine:2.0.5'
}
执行createSWRLRuleEngine方法时出现异常:
public void addNewSWRLRule(SWRLRuleModel rule) throws SWRLBuiltInException, SWRLParseException {
SWRLRuleEngine swrlRuleEngine = SWRLAPIFactory.createSWRLRuleEngine(ontology);
swrlRuleEngine.infer();
swrlRuleEngine.createSWRLRule(rule.getName(), rule.getRule(), rule.getComment(), true);
}
是否有必须手动添加的依赖才能解决此问题?
最佳答案
您正在使用 HermiT 1.4.1.513。这与 owlapi 5 兼容,而不是 4(补丁号与 owlapi 版本匹配)。使用 HermiT 1.3.8.413。
关于java - 使用 gradle 使用 SWRL API 创建 SWRL 规则的依赖性问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52273755/