Question

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)

Was it helpful?

Solution 2

If I wanted to create a modelling element such as a class without instances from an input string I would do something like:

OWLEntity entity = factory.getOWLEntity(EntityType.CLASS, IRI.create(input));

The EntityType.CLASS could be changed to other elements such as EntityType.ObjectProperty. This is the way I approach this problem and when I want to add instances I just add a new axiom to the ontology manager.

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top