Ped*_*dro 6 inference ontology sparql jena protege
我想使用Jena的推理功能,但是当我使用InfModel时,我遇到了一些性能问题.
以下是我的本体的简要概述:
属性:
hasX (Ranges(intersection): X, inverse properties: isXOf)
|-- hasSpecialX (Ranges(intersection): X, inverse properties: isSpecialXOf)
isXOf (Domains(intersection): X, inverse properties: hasX)
|--isSpecialXOf (Domains(intersection): X, inverse properties: hasSpecialX)
Run Code Online (Sandbox Code Playgroud)
此外还有一个"对象"类:
Object hasSpecialX some X
Run Code Online (Sandbox Code Playgroud)
显式存储的是以下数据:
SomeObject a Object
SomeX a X
SomeObject hasSpecialX SomeX
Run Code Online (Sandbox Code Playgroud)
使用以下查询,我想确定一个实例属于哪个类.根据所做的假设,只应返回'SomeObject'.
SELECT ?x WHERE { ?x :hasX :SomeX . }
Run Code Online (Sandbox Code Playgroud)
但是,查询ds.getDefaultModel()不起作用,因为数据未显式存储.infModel另一方面,当我使用时,查询永远不会完成.最长的我在流产前等了25分钟.(三元店的大小约为180 MB)
这是我的代码:
OntModel ont = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_MICRO_RULE_INF, null);
ont.read("file:..." , "RDF/XML");
Reasoner reasoner = ReasonerRegistry.getOWLMicroReasoner();
reasoner = reasoner.bindSchema(ont);
Dataset dataset = TDBFactory.createDataset(...);
Model model = dataset.getDefaultModel();
InfModel infModel = ModelFactory.createInfModel(reasoner, model);
QueryExecution qe = null;
ResultSet rs;
try {
String qry = "SELECT ?x WHERE { ?x :hasX :SomeX . }";
qe = QueryExecutionFactory.create(qry, infModel);
rs = qe.execSelect();
while(rs.hasNext()) {
QuerySolution sol = rs.nextSolution();
System.out.println(sol.get("x"));
}
} finally {
qe.close();
infModel.close();
model.close();
dataset.close();
}
Run Code Online (Sandbox Code Playgroud)
上面的代码有什么问题,或者其他什么原因可能不起作用?
除此之外,我想知道如果我将'推断公理导出为本体'(由Protege提供)是否可以提高性能?
编辑: 我同时我尝试使用Pellet,但我仍然无法获得推断模型,正如我在另一个问题中描述的那样:使用Pellet作为推理器的OutOfMemoryError.那么我还能做些什么呢?