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[]
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:I expect that if you add photo1's
OWLDeclarationAxiom
s first (which it looks like you'd retrieve usinggetAxioms(AxiomType<Declaration>)
, and then add its ABoxAxioms, you might get the results that you're expecting.