推断具有整数基数约束的实例时出现问题
我使用 Protege 4.1 alpha 创建了一个 RDF/OWL 文件。 我还在 Protege 中创建了一个定义的类,名为 CheapPhone。该类有一个限制,如下所示:
(hasPrice some integer[< 350])
每当手机价格低于 350 时,就将其推断为 CheapPhone。 在 Protege 4.1 alpha 中推断这一点没有问题。但是,我无法使用耶拿来推断这一点。
我还创建了一个名为 SmartPhone 的定义类。该类还有一个限制,如下所示:
(has3G value true) and (hasInternet value true)
只要一部手机具有 3G 和互联网功能,就被推断为 SmartPhone。 在这种情况下,在Protege和Jena中推断这一点是没有问题的。
我开始认为耶拿的默认推理引擎有问题。 我在 Java 中使用的代码如下:
Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
reasoner = reasoner.bindSchema(ontModel);
OntModelSpec ontModelSpec = OntModelSpec.OWL_MEM_MINI_RULE_INF;
ontModelSpec.setReasoner(reasoner);
// Create ontology model with reasoner support
// ontModel was created and read before, so I don't share the code in order
// not to create garbage here
OntModel model = ModelFactory.createOntologyModel(ontModelSpec, ontModel);
OntClass sPhone = model.getOntClass(ns + "SmartPhone");
ExtendedIterator s = sPhone.listInstances();
while(s.hasNext()) {
OntResource mp = (OntResource)s.next();
System.out.println(mp.getURI());
}
该代码工作完美并返回实例,但是当我更改下面的代码并使其适合 CheapPhone 时,它不会返回任何内容。
OntClass sPhone = model.getOntClass(ns + "CheapPhone");
我做错了什么吗?
I have created an RDF/OWL file using Protege 4.1 alpha.
I also created a defined class in Protege called CheapPhone. This class has a restriction which is shown below :
(hasPrice some integer[< 350])
Whenever, a price of a phone is below 350, it is inferred as CheapPhone.
There is no problem for inferring this in Protege 4.1 alpha. However, I cannot infer this using Jena.
I also created a defined class called SmartPhone. This class also has a restriction which is shown below :
(has3G value true) and (hasInternet value true)
Whenever, a phone has 3G and Internet, it is inferred as SmartPhone.
In this situation, there is no problem inferring this in both Protege and Jena.
I have started to think that there is a problem in default inference engine of Jena.
The code that I use in Java is below :
Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
reasoner = reasoner.bindSchema(ontModel);
OntModelSpec ontModelSpec = OntModelSpec.OWL_MEM_MINI_RULE_INF;
ontModelSpec.setReasoner(reasoner);
// Create ontology model with reasoner support
// ontModel was created and read before, so I don't share the code in order
// not to create garbage here
OntModel model = ModelFactory.createOntologyModel(ontModelSpec, ontModel);
OntClass sPhone = model.getOntClass(ns + "SmartPhone");
ExtendedIterator s = sPhone.listInstances();
while(s.hasNext()) {
OntResource mp = (OntResource)s.next();
System.out.println(mp.getURI());
}
This code works perfectly and returns me the instances, but when I change the code below and make it appropriate for CheapPhone, it doesn't return anything.
OntClass sPhone = model.getOntClass(ns + "CheapPhone");
Am I doing something wrong ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
数据范围(
[<350]
位)是 OWL 2 的一项功能。Jena 不支持 OWL 2。请参阅 W3C 的 OWL 2 实现页面,获取支持 OWL 2 的工具列表 — 您必须使用其中一个。 (那里列出了耶拿正在进行的一些实验性工作,但这肯定还没有进入耶拿版本。)Data ranges (the
[< 350]
bit) is a feature of OWL 2. Jena doesn't support OWL 2. See W3C's OWL 2 Implementations page for a list of tools with OWL 2 support—you'll have to use one of those. (Some experimental ongoing work for Jena is listed there, but this definitely hasn't made it into a Jena release yet.)