I got a small ontology with the individuals. Some of these individuals should be connected with each other through symmetric ObjectProperty
.
I need to use Pellet reasoner, so that it could synchronize and attach symmetric ObjectProperty
to the individuals.
I use the OWLAPI to create the ontology. My code for the creation of ObjectProperty
is:
// create the OWLObjectProperty isLinkedTo
OWLObjectProperty isLinkedTo = factory.getOWLObjectProperty(IRI.create(ontologyIRI + "#" +hasLinkStr));
// create a set for the axioms (OPAS - Obj.Prop.Axioms Set)
Set<OWLAxiom> isLinkedOPAS = new HashSet<OWLAxiom>();
// add the OWLObjectProperty isLinkedTo to the set isLinkedOPAS
OWLNamedIndividual prevNamedInd = factory.getOWLNamedIndividual(prevIndividual, pm);
isLinkedOPAS.add(factory.getOWLSymmetricObjectPropertyAxiom(isLinkedTo));
//setting the object property for the current (namedInd) and previous (prevNamedInd)individuals
isLinkedOPAS.add(factory.getOWLObjectPropertyAssertionAxiom(isLinkedTo, namedInd, prevNamedInd));
manager.addAxioms(ontology, isLinkedOPAS);
The individuals are created one after each other. Every next individual isLinkedTo
previous one with the symmetrical property.
Then, I start the reasoner, but I am not sure if I do it in the right way:
OWLReasoner reasoner = reasonerFactory.createReasoner(ontology, config);
// I am not sure which of these commands is necessary for checking the ObjectProperty assertions
reasoner.precomputeInferences();
reasoner.precomputeInferences(InferenceType.OBJECT_PROPERTY_ASSERTIONS);
reasoner.precomputeInferences(InferenceType.OBJECT_PROPERTY_HIERARCHY);
boolean consistent = reasoner.isConsistent();
System.out.println("Consistent: " + consistent);
When I open this ontology in Protege, it shows me the individuals, but not "connected" symmetrically with the ObjectProperty
isLinkedTo:
It shows the right way only after the running reasoner in Protege:
So the question is: What should I write in the code in order to obtain the ontology where the Object Properties are synchronized by the reasoner?