简体   繁体   English

owlapi HERMIT和SPARQL

[英]owlapi HERMIT and SPARQL

How is it possible to execute a SPARQL Query in Java using the HERMIT reasoner 1.3.8? 如何使用HERMIT推理程序1.3.8在Java中执行SPARQL查询? I'm using owlapi 4.2 and i have loaded the HERMIT reasoner using: 我正在使用owlapi 4.2,并且已使用以下命令加载了HERMIT推理程序:

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?! 不幸的是,我找不到任何解释如何使用此推理器执行SPARQL查询? Is this possible at all? 这有可能吗? If not, what other possibilities (other reasoners) do i have using owlapi and SPARQL? 如果没有,使用owlapi和SPARQL还有什么其他可能性(其他推理程序)?

EDIT: 编辑:

I now know that i need a SPARQL Engine. 我现在知道我需要一个SPARQL引擎。 This is why i used SPARQL-DL like this: 这就是为什么我这样使用SPARQL-DL的原因:

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 ? 如何获取http://www.example.com/project1#document_1 I could not find a proper Method for getting this value. 我找不到获取此值的正确方法。

HermiT is an OWL reasoner and not a SPARQL engine. HermiT是OWL推理程序,而不是SPARQL引擎。 There is an API called SPARQL-DL, but according to its website it supports just OWL API v3.x. 有一个名为SPARQL-DL的API,但根据其网站,它仅支持OWL APIv3.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 可以在Protege项目中找到具有OWL API 4支持的较新的分支版本: https : //github.com/protegeproject/sparql-dl-api

Looking at the source for QueryResult, available here , what you have there is a query binding. 查看QueryResult的源( 可从此处获得),这里有一个查询绑定。 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. 您具有迭代所有绑定的方法,并且应该在绑定的绑定值中找到要获取的值。

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

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