Discipulos
Discipulos

Reputation: 469

How to add rdfs:label to OWLIndividual via OWLAPI?

I would like to add an rdfs:label to an OWLIndividual, I have the following:

OWLIndividual newIndividual = factory.getOWLNamedIndividual(IRI.create(name));
OWLLiteral lbl = factory.getOWLLiteral(name);
OWLAnnotation label =
  factory.getOWLAnnotation( 
    factory.getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_LABEL.getIRI()), lbl);

Now, how can I associate the label to the individual?

Upvotes: 2

Views: 1084

Answers (1)

loopasam
loopasam

Reputation: 3136

You can associate the label the following way:

OWLAxiom axiom = factory.getOWLAnnotationAssertionAxiom(newIndividual.asOWLNamedIndividual().getIRI(), label);
manager.applyChange(new AddAxiom(ontology, axiom));

In this case you need to work with a NamedIndividual in order to retrieve the IRI to assert the annotation.

Upvotes: 2

Related Questions