将SWRL与Jena和Pellet一起使用 [英] Using SWRL with Jena and Pellet

查看:544
本文介绍了将SWRL与Jena和Pellet一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找不到使用SWRL和Jena的一些不错的简单代码示例, 造粒,还是至少使用SWRL?我已经在Pellet文档中研究了一些示例,但是没有关于使用SWRL的示例.网络上的大多数示例都是不完整且令人困惑的.

I was unable to find some decent simple code examples of using SWRL and Jena with Pellet, or at least using SWRL? I have studied some examples in Pellet documentation, but there is no example about using SWRL. Most examples on the web are incomplete and confusing.

我找到的唯一解决方案是使用Jess Rule Engine,但它不是免费的,并且已获得商业许可.我发现Pellet支持SWRL规则,但找不到运行示例.

The only solution I found was with the Jess Rule Engine but it is not free and is under commercial license. I found that Pellet support SWRL rules but could not find running example.

我发现的唯一例子是这个,但我不明白:

The only example I found is this, but I do not understand it:

OWLOntologyManager m = create();
OWLOntology o = m.createOntology(example_iri);
// Get hold of references to class A and class B.
OWLClass clsA = df.getOWLClass( IRI.create(example_iri +    "#A" ));
OWLClass clsB = df.getOWLClass(IRI.create(example_iri +    "#B"    ));
SWRLVariable var = df.getSWRLVariable(IRI.create(example_iri + "#x" ));
SWRLClassAtom body = df.getSWRLClassAtom(clsA, var);
SWRLClassAtom head = df.getSWRLClassAtom(clsB, var);
SWRLRule rule = df.getSWRLRule(Collections.singleton(body),
Collections.singleton(head));
m.applyChange(new AddAxiom(o, rule));

推荐答案

造物规则和耶拿规则大相径庭.

简短的答案是Pellet支持SWRL规则.如果您的本体包含SWRL规则并要求Pellet对其进行推理,则会将其考虑在内.

Pellet Rules and Jena Rules are Very Different™

The short answer is that Pellet supports SWRL rules. If you have an ontology that contains SWRL rules and ask Pellet to reason over it, it will take them into consideration.

Jena具有自己的规则语言,在文档页面原因和规则引擎中进行了描述:Jena推理支持.它支持正向和反向链接规则.

Jena has its own rules language, which is described in the documentation page, Reasoners and rule engines: Jena inference support. It supports both forward and backward chaining rules.

但是,尽管Pellet和Jena都支持规则的概念,但是SWRL规则和Jena规则的预期领域却大不相同. SWRL规则是OWL级别的构造; SWRL规则中的一元谓词是类表达式,而二元谓词是对象和数据属性.此外,SWRL规则仅在指定的个人上匹配;它们与仅能推断其存在的个人不匹配.另一方面,Jena规则是RDF级别的,旨在在RDF图形上使用.尽管RDF和OWL通常一起使用(例如,OWL数据在RDF中序列化),但两者在概念上是截然不同的.可以实现不使用RDF的OWL推理程序,并且可以构建不使用RDF图的SWRL引擎.

However, though both Pellet and Jena support a notion of rules, the intended domains of SWRL rules and Jena rules are very different. SWRL rules are OWL-level constructs; the unary predicates in a SWRL rule are class expressions, and the binary predicates are object and data properties. Additionally, SWRL rules only match on named individuals; they don't match for individuals whose existence is only inferred. Jena rules, on the other hand, are RDF-level, and designed to work on RDF-graphs. While RDF and OWL are often used together, (e.g., OWL data is serialized in RDF), the two are conceptually distinct. An OWL reasoner could be implemented that makes no use of RDF, and a SWRL engine could be built that make no use of RDF graphs.

基于

The code that you've shown, based on the presence of an OWLOntologyManager, is based on the OWL API, not on Jena's API. The OWL API will have more direct functionality for working with OWL and SWRL rules, while Jena will not. (Jena's OntModels work well with OWL1, but support for OWL2 is not complete (and still "open for contributors").

您可能会发现使用Protégé之类的编辑器来创建规则会比使用OWL API或尝试使用Jena的API更容易. Martin Kuba撰写了非常不错的 OWL2和SWRL教程,可以在这里为您提供帮助.

Rather than using the OWL API or trying to use Jena's API, you'll probably find it easier to create rules using an editor such as Protégé. Martin Kuba has written a very nice OWL2 and SWRL Tutorial that can help you here.

这篇关于将SWRL与Jena和Pellet一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆