簡體   English   中英

如何與耶拿一起使用及物推理器?

[英]How to use Transitive Reasoner with Jena?

我想與耶拿(Jena)一起建立TransitiveReasoner,以根據架構和數據集創建新的推理模型。 它適用於RDFS推理程序,但不適用於TransitiveReasoner。

這是我的第一個推理經驗。 我查看了Jena推理支持以及其他教程,但無法解決我的問題。

這是我在Java中的測試代碼:

import com.hp.hpl.jena.ontology.*;
import com.hp.hpl.jena.rdf.model.*;
import com.hp.hpl.jena.reasoner.*;
import com.hp.hpl.jena.vocabulary.*;

public class TestInference 
{

    public static void myTest() throws IOException
    {
      String NS = "testInference:";
      OntModel schema = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, null);
      OntClass m = schema.createClass(NS + "Mention");
      OntClass pm = schema.createClass(NS + "PersonMention");
      pm.addProperty(RDFS.subClassOf, m);

      Model data = ModelFactory.createDefaultModel();
      Resource r = data.createResource(NS+"alberto");
      r.addProperty(RDF.type, pm);

      Reasoner rdfsReasoner = ReasonerRegistry.getRDFSSimpleReasoner();
      Reasoner transReasoner = ReasonerRegistry.getTransitiveReasoner();

      System.out.println("\n===== RDSF =====");
      InfModel rdfsInf = ModelFactory.createInfModel(rdfsReasoner, schema, data);
      rdfsInf.write(System.out, "TURTLE");

      System.out.println("\n===== Trans =====");
      InfModel transInf = ModelFactory.createInfModel(transReasoner, schema, data);
      transInf.write(System.out, "TURTLE");
}

public static void main(String[] args) throws IOException
{
    myTest();
}

嘗試更改OntModelSpec沒有幫助。

我究竟做錯了什么?

在此先感謝您的幫助。

TransitiveReasoner僅處理RDFS subClassOf和RDFS subPropertyOf 它不提供rdf:type的步驟。

A subClassOf B . B subClassOf C => A subClassOf C

但不是這一部分:

x type T . T subClassOf S => x type S

https://jena.apache.org/documentation/inference/#transitive

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM