Search code examples
javasparqlowl-api

owlapi HERMIT and SPARQL


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.


Solution

  • 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