我正在使用耶拿TDB。我成功地存儲了三元組,但需要指定某個屬性「isA」是可傳遞的,以便使用TransitiveReasoner進行推理。我加載模型如下需要使財產transitive
private void AddTriple(String arg1, String pred, String arg2) {
Resource r = m.createResource(NS + arg1);
Property p = m.createProperty(NS + pred);
Property p2 = m.createProperty(NS + arg2);
r.addProperty(p, p2);
}
private void addTest() {
AddTriple("cat", "isA", "feline");
AddTriple("feline", "isA", "mammal");
AddTriple("mammal", "isA", "animal");
m.close();
}
:
Dataset dataset = TDBFactory.createDataset(directory);
m = dataset.getDefaultModel();
addTest();
我設立的推理如下:
以下是一些方法,我使用
Reasoner reasoner = ReasonerRegistry.getTransitiveReasoner();
InfModel inference = ModelFactory.createInfModel(reasoner, m);
推理模型包含:
<ModelCom {http://namespace/test#cat @http://namespace/test#isA http://namespace/test#feline; http://namespace/test#feline @http://namespace/test#isA http://namespace/test#mammal; http://namespace/test#mammal @http://namespace/test#isA http://namespace/test#animal} | >
由於「isA」屬性沒有被指定爲可傳遞的,所以推理模型包含與原始模型完全相同的三元組。我怎麼可以指定「ISA」屬性是傳遞這樣我就可以得到下面的三元組:
cat isA mammal
cat isA animal
感謝完美的作品使用OWL推理機! – dscer 2012-03-25 16:28:25
很好,感謝您讓我們知道並記住「官方」Apache Jena支持是通過jena-users郵件列表查看如何訂閱郵件列表的詳細信息:http://incubator.apache.org/jena/help_and_support/ – castagna 2012-03-25 18:40:10