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