简体   繁体   English

OWL中没有与DL查询有关的推论-API

[英]no inferences with DL queries in OWL - API

I am trying to write a query 我正在尝试编写查询

Hospitals and hasNameWithWords value "center"^^string 医院和hasNameWithWords值“中心” ^^字符串

This query returns me the instances that has the hospitals that has "center" in its name in Protege 4.2 with FACT++ reasoner as well as Hermit reasoner 此查询返回我的实例,该实例的医院在Protege 4.2中使用FACT ++推理程序和隐士推理程序,其名称中具有“中心”

but when i input the same query in the OWL-API's DL Query Example thats available in the website http://sourceforge.net/p/owlapi/code/ci/aef6981535f07a2d0d44c394b9f4d5415f36025a/tree/contract/src/test/java/org/coode/owlapi/examples/DLQueryExample.java 但是当我在OWL-API的DL查询示例中输入相同的查询时,该查询可在以下网站上找到: http://sourceforge.net/p/owlapi/code/ci/aef6981535f07a2d0d44c394b9f4d5415f36025a/tree/contract/src/test/java/org/ coode / owlapi / examples / DLQueryExample.java

I don't get any result. 我没有任何结果。

But it gives me result when i write simple queries such as 但是当我编写简单的查询(例如,

Hospitals 医院

Is it because the reasoner in the code is not able to make the inference? 是因为代码中的推理程序无法进行推理吗?

What other reasoner would be better? 还有什么其他理由会更好?

The class you use as example ( DLQueryExample.java ) relies on an OWL-API built-in structural reasoner ( OWLReasonerFactory reasonerFactory = new StructuralReasonerFactory(); ). 您作为示例使用的类( DLQueryExample.java )依赖于OWL-API内置的结构推理器OWLReasonerFactory reasonerFactory = new StructuralReasonerFactory(); )。

This type of reasoner is fairly simple and is not suited for complex queries as yours. 这种类型的推理程序非常简单,不适合像您这样的复杂查询。 It can however provide answers on the class hierarchy: This is why you get some results with the straightforward query Hospitals . 但是,它可以提供有关类层次结构的答案:这就是为什么通过直接查询Hospitals可以获得一些结果的原因。

What you need to do is to set your code to either use Hermit or FACT++. 您需要做的是将代码设置为使用隐士或FACT ++。 I give the example with Hermit : 我以隐士为例:

  • Download HermiT jar file and add it to the class path of your project. 下载 HermiT jar文件并将其添加到项目的类路径。
  • In your class, replace the line OWLReasonerFactory reasonerFactory = new StructuralReasonerFactory(); 在您的类中,替换行OWLReasonerFactory reasonerFactory = new StructuralReasonerFactory(); by: OWLReasonerFactory reasonerFactory = new Reasoner.ReasonerFactory(); 创建人: OWLReasonerFactory reasonerFactory = new Reasoner.ReasonerFactory(); . You should have to import org.semanticweb.HermiT.Reasoner in order to make it work. 为了使其工作,您必须导入org.semanticweb.HermiT.Reasoner
  • We just replaced the default reasoner by HermiT. 我们只是将默认推理机替换为HermiT。 The rest of the code should stay the same and your query should now work. 其余代码应保持不变,并且您的查询现在应该可以正常工作。
  • You could try FaCT++ and Pellet and compare speed, etc... 您可以尝试使用FaCT ++Pellet并比较速度等。

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

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