dscer
dscer

Reputation: 228

Need to make a property transitive

I am using Jena with TDB. I am successfully storing triples but need to specify that a certain property "isA" is transitive in order to use the TransitiveReasoner for inference.

The following is some of the methods I am using:

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();
}

I am loading the model as follows:

Dataset dataset = TDBFactory.createDataset(directory);
m = dataset.getDefaultModel();
addTest();

I am setting up the reasoner as follows:

Reasoner reasoner = ReasonerRegistry.getTransitiveReasoner();    
InfModel inference = ModelFactory.createInfModel(reasoner, m);

The inference model contains:

<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} | >

Since the "isA" property is not specified as being transitive the inference model contains the exact same triples as the original model. How I can specify that the "isA" property is transitive so I can get the following triples:

cat isA mammal
cat isA animal

Upvotes: 1

Views: 771

Answers (1)

castagna
castagna

Reputation: 1359

"When one defines a property P to be a transitive property, this means that if a pair (x,y) is an instance of P, and the pair (y,z) is also instance of P, then we can infer the the pair (x,z) is also an instance of P. Syntactically, a property is defined as being transitive by making it an instance of the the built-in OWL class owl:TransitiveProperty, which is defined as a subclass of owl:ObjectProperty." -- http://www.w3.org/TR/owl-ref/#TransitiveProperty-def

Therefore, you need to define your property as being transitive, you can do that by adding the following RDF triple to your Jena Model:

<http://namespace/test#isA> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#TransitiveProperty>

m.add ( ResourceFactory.createResource(NS + "isA"), RDF.type, OWL.TransitiveProperty )

I also recommend you read the documentation on the Jena website relative to ontologies and inference:

Upvotes: 2

Related Questions