-->

耶拿:如何推断数据/性能问题(Jena: How to infer data / performan

2019-09-16 13:38发布

我想使用耶拿的推理能力,但我有,当我使用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)

此外还有一类“对象”:

Object hasSpecialX some X

明确地存储是以下数据:

SomeObject a Object 
SomeX a X
SomeObject hasSpecialX SomeX  

使用下面的查询,我想确定一个实例属于哪一类。 根据所作的假设,只有“SomeObject”应该返回。

SELECT ?x WHERE { ?x :hasX :SomeX . } 

然而,查询对ds.getDefaultModel()不起作用,因为数据没有明确存储。 当我使用infModel ,另一方面,查询永远不会完成。 在最长的我已经中止之前等待25分钟。 (该triplestore的尺寸为约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();
}

这有什么错与上面的代码,或者还有什么可能是它不工作的原因是什么?

除此之外,我想知道如果我这样做“导出推断公理作为本体论”(由门生提供)我可以提高性能?

编辑:我我试过同时用颗粒,但我仍然不能得到推断模型,正如我在我的其他问题已经描述: OutOfMemoryError错误使用颗粒作为理性者 。 所以,还有什么我能做什么?

Answer 1:

至于性能,更好地断言数据,而不是之前做的推断,并与耶拿推理机制关做SPARQLs。 您正在使用TDB其右耶拿组件,用于大数据集。

如果使用推断的数据直接你没有得到预期的表现那么我建议移动到一个更具扩展性的三店( 4store或炫技 )。



文章来源: Jena: How to infer data / performance issues