I have a requirement to create a class in the Ontology using the OWL-API without adding any instances.
I checked the examples and the documentation but all the places the classes are created along with the individuals/ instances. Is there a way to create classes without any instances (and and them later on)
It is never necessary to add instances to declare and use a class.
For example:
OWLClass c = factory.getOWLClass(IRI.create(cInput));
OWLAxiom declareC = factory.getOWLDeclarationAxiom(c);
// adding declareC to the ontology is necessary to have any output
manager.addAxiom(ontology, declareC);
In order to get any entity outputted when saving an ontology, it must be used in some axiom included in the ontology. In this example, that axiom is the class declaration; it could be a subclass axiom or an assertion (in that case, an instance will be created).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With