문제

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)

도움이 되었습니까?

해결책 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.

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top