How to add rdfs:label to OWLIndividual via OWLAPI?

半腔热情 提交于 2019-12-22 11:47:28

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/17902623/how-to-add-rdfslabel-to-owlindividual-via-owlapi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!