.annotation_properties() does not include rdfs: properties
I am writing code that involves using owlready2 to loop through all annotation properties in an owl file, but for some reason the list of annotation properties I get from the generator obtained using the .annotation_properties() method does not include "rdfs:" annotation properties. E.g., rdfs:label and rdfs:comment are not included in the list although they are used to annotate classes in the owl file I am analysing.
I manage to retrieve all these standard annotations like follows :
import importlib, inspect
for name, cls in inspect.getmembers(importlib.import_module("owlready2.annotation"), inspect.isclass):
if type(cls).__name__ == 'AnnotationPropertyClass':
I would like then to get the ones having 'ClassInspectorAnnotation' as an annotation, so I call
It works fine on the annotations listed in the onto.annotation_properties() method, but it fails on the "default" annotations. I get the following error message :
AttributeError: 'ClassInspectorAnnotation' annotation property is not defined.
Re: .annotation_properties() does not include rdfs: properties
Thank you for reporting this problem, I've just fixed it in the development version of Owlready on Bitbucket.
You can now annotate the predefined annotations. However, as they are not defined in a particular ontology, you need to specify the ontology in which the annotation is added, using a "with" block, e.g.:
Alternatively, you may also add an RDF triple directlty as follows:
onto._add_data_triple_raw_spod(comment.storid, ClassInspectorAnnotation.storid, *default_world._to_rdf("annotation value 2"))