Reasoner returns no instances of owl:Thing, but Abox contains instances

160 views Asked by At

I have two ontologies, photo1 and index. Photo1 contains ABox assertions, and index contains Tbox assertions.

OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLOntology photo1 = manager.loadOntologyFromOntologyDocument(new File("files/ontologies/OBMA2/photo1.owl"));
OWLDataFactory factory = manager.getOWLDataFactory();
reasoner = new FaCTPlusPlusReasonerFactory().createReasoner(photo1);
reasoner = (FaCTPlusPlusReasoner) reasoner;
System.out.println(reasoner.getInstances(factory.getOWLThing(), false));

The above prints:

Nodeset[
  Node( <http://www.semanticweb.org/noor/ontologies/2013/6/photo1.owl#photo1> ),
  Node( <http://www.semanticweb.org/noor/ontologies/2013/6/photo1.owl#photo1-tiger2> ),
  Node( <http://www.semanticweb.org/noor/ontologies/2013/6/photo1.owl#photo1-tiger1> )
]

However, now, I'm loading the Tbox and adding all ABox axioms from photo1 and then getting instances of owl:Thing as follows:

OWLOntologyManager managerTbox = OWLManager.createOWLOntologyManager();
OWLOntology Tbox = manager.loadOntologyFromOntologyDocument(new File("files/ontologies/index.owl"));
OWLDataFactory factoryTbox = manager.getOWLDataFactory();
OWLReasoner reasonerTbox = new FaCTPlusPlusReasonerFactory().createReasoner(Tbox);

//adding the axioms from the photo1 abox to Tbox's abox
managerTbox.addAxioms(Tbox, photo1.getABoxAxioms(true));
reasonerTbox = (FaCTPlusPlusReasoner) reasonerTbox;
System.out.println(reasonerTbox.getInstances(factoryTbox.getOWLThing(), false));

Now, even though I have added all axioms from Photo1's ABox to TBox's ABox, I get no output:

Nodeset[]
2

There are 2 answers

0
Joshua Taylor On

I'm not much of an OWL API user, but I suspect that what's happening is that the ABox axioms that you're including in the second case don't include the individual declarations for the individuals that the axioms talk about, and that as a result, the ABox axioms are getting ignored.

From the OWLAPI source, the ABoxAxiomTypes are defined as:

public static final Set<AxiomType<?>> ABoxAxiomTypes = new HashSet<AxiomType<?>>(
        Arrays.asList(CLASS_ASSERTION, SAME_INDIVIDUAL,
                DIFFERENT_INDIVIDUALS, OBJECT_PROPERTY_ASSERTION,
                NEGATIVE_OBJECT_PROPERTY_ASSERTION,
                DATA_PROPERTY_ASSERTION, NEGATIVE_DATA_PROPERTY_ASSERTION,
                DATATYPE_DEFINITION));

I expect that if you add photo1's OWLDeclarationAxioms first (which it looks like you'd retrieve using getAxioms(AxiomType<Declaration>), and then add its ABoxAxioms, you might get the results that you're expecting.

0
Ignazio On

You are creating a buffering reasoner with the first call to the reasoner factory; then you are adding the axioms to the ontology correctly, but the reasoner will not see the updates until you call reasoner.flush().

You can create a non-buffering reasoner with the same factory (see OWLReasonerFactory.createNonBufferingReasoner()), but this might have performance repercussions, as there might be a reclassification at every change.