[英]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.