Reputation: 518
How is it possible to execute a SPARQL Query in Java using the HERMIT reasoner 1.3.8? I'm using owlapi 4.2 and i have loaded the HERMIT reasoner using:
OWLReasonerFactory reasonerFactory = new Reasoner.ReasonerFactory();
OWLReasoner reasonerHermit = reasonerFactory.createReasoner(ontology);
Unfortunately i could not find any explanation how to execute a SPARQL Query with this reasoner?! Is this possible at all? If not, what other possibilities (other reasoners) do i have using owlapi and SPARQL?
EDIT:
I now know that i need a SPARQL Engine. This is why i used SPARQL-DL like this:
QueryEngine engine = QueryEngine.create(manager, reasoner, true);
Query query = Query.create("...");
QueryResult result = engine.execute(query);
System.out.println(result);
The query works, but if I'm now getting something like
?de.derivo.sparqldlapi.Var@69 = http://www.example.com/project1#document_1
how do i get out the http://www.example.com/project1#document_1
? I could not find a proper Method for getting this value.
Upvotes: 0
Views: 741
Reputation: 10659
Looking at the source for QueryResult, available here, what you have there is a query binding. You have methods to iterate over all the bindings, and you should find the value you are after in the bound values of the binding.
Upvotes: 2
Reputation: 8465
HermiT is an OWL reasoner and not a SPARQL engine. There is an API called SPARQL-DL, but according to its website it supports just OWL API v3.x. A newer forked version with OWL API 4 support can be found as part of the Protege project: https://github.com/protegeproject/sparql-dl-api
Upvotes: 3