owlcs/owlapi

Unable to fetch annotations from OWLClass

Closed this issue · 1 comments

Hi, I have few annotations defined for a class in RDF, I am not able to fetch them from the api. Here is what I tried,

ontology.getAnnotations(new OWLAnnotationPropertyImpl(owlClass.getIRI()));

This is returning empty list. Can someone help me how to extract them?

ontology::getAnnotations is looking for annotation axioms where the input annotation matches the annotation property; using the owlClass IRI is unlikely to work because owl classes and annotation properties should not have the same IRI (forbidden punning in OWL). Unless in your ontology the annotation property IRI actually matches the class IRI, no results are expected.

Use
EntitySearcher.getAnnotationObjects(owlClass, ontology)
instead.

Note: do not instantiate manually Impl classes, use an instance of OWLDataFactory instead. OWLManager can be used to get data factory instances.