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. 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!

asked 06 Nov '12, 19:28

dadalocsin's gravatar image

dadalocsin
234
accept rate: 0%


Ok, I have posted the same question in the jena mailing list. According to Dave Reynolds, The reasoner works within a model and not across different models.

Therefore the answer should be to use say, only modelA for instance so that all of the individuals are stored within it.

The answer to this question can also be found here http://jena.markmail.org/thread/is3pyrz3xdj5b7ma

link

answered 07 Nov '12, 07:01

dadalocsin's gravatar image

dadalocsin
234
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×591
×578
×169

Asked: 06 Nov '12, 19:28

Seen: 877 times

Last updated: 07 Nov '12, 07:01