On 07/11/12 00:32, Joseph Daryl Locsin wrote:
I am trying to tie up two identical individuals from different sources. My
idea is that, if IndividualA has a missing property P but is tied up to
IndividualB with an existing P using OWL.sameAs, then the inferencer should
output that IndividualA has P! I am confused why this isn't working.

The reasoners work on a model, you have split your information across three different models with three different reasoners so no one instance can see all necessary information.

Put both donaldA and donaldB in the same model along with the hasFeatures assertion and sameAs assertion.

Dave


This
is my code.

     public class Main {

     static String NS_A = "http://www.namespacea.com/ontoa.owl#";;
     static String NS_B = "http://www.namespaceb.com/ontob.owl#";;
     static String NS_C = "http://www.namespacec.com/ontoc.owl#";;

     public static void main(String[] args) {

         OntModelSpec spec = OntModelSpec.OWL_MEM_MINI_RULE_INF;

         OntModel modelA = ModelFactory.createOntologyModel(spec);
         OntModel modelB = ModelFactory.createOntologyModel(spec);
         OntModel modelC = ModelFactory.createOntologyModel(spec);

         // Populate Model A
         OntClass animal = modelA.createClass(NS_A + "Animal");
         OntProperty hasFeathers = modelA.createOntProperty(NS_A +
"hasFeathers");
         hasFeathers.addDomain(animal);
         hasFeathers.addRange(XSD.xboolean);

         // Populate Model B
         OntClass duck = modelB.createClass(NS_B + "Duck");
         duck.setSuperClass(animal);
         Individual donaldA = modelB.createIndividual(NS_B + "DonaldDuck", 
duck);

         // NEXT LINE IS REMOVED ON PURPOSE
         //donaldA.addLiteral(hasFeathers, true);

         //Populate Model C
         Individual donaldB = modelC.createIndividual(NS_C + "DonaldDuck", 
duck);

         // Donald hasFeathers IS DECLARED HERE
         donaldB.addLiteral(hasFeathers, true);

         // THIS TIES UP THE TWO INDIVIDUALS
         donaldA.addProperty(OWL.sameAs, donaldB);

         // Query
         System.out.println(
             "Does " + donaldA.getLocalName() +
             " have feathers? " + "Ans. " +
donaldA.getPropertyValue(hasFeathers).asLiteral().getValue()
         );
     }
}

The result is a NullPointerException. How do you solve this problem?

A more difficult scenario that I've thought of is, if there are Individuals
A, B, C, D and E s.t. A isSameAs B, B isSameAs C, and so forth, where E has
P = true. Then asking if A has P = true should say TRUE!


Reply via email to