问题
I am trying to write a query
Hospitals and hasNameWithWords value "center"^^string
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
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
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?
回答1:
The class you use as example (DLQueryExample.java
) relies on an OWL-API built-in structural reasoner (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
.
What you need to do is to set your code to either use Hermit or FACT++. I give the example with Hermit:
- Download HermiT jar file and add it to the class path of your project.
- In your class, replace the line
OWLReasonerFactory reasonerFactory = new StructuralReasonerFactory();
by:OWLReasonerFactory reasonerFactory = new Reasoner.ReasonerFactory();
. You should have to importorg.semanticweb.HermiT.Reasoner
in order to make it work. - We just replaced the default reasoner by 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...
来源:https://stackoverflow.com/questions/14353303/no-inferences-with-dl-queries-in-owl-api