.annotation_properties() does not include rdfs: properties

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

.annotation_properties() does not include rdfs: properties

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

Is this a bug or is it happening for a reason?
Reply | Threaded
Open this post in threaded view
|

Re: .annotation_properties() does not include rdfs: properties

Jiba
Administrator
Hi,

The label and comment annotation are not defined in your ontology, as a consequence, they are not listed by annotation_properties().

If you want to include OWL "builtin" annotations, you need to add label, comment, backwardCompatibleWith, deprecated, incompatibleWith, isDefinedBy, priorVersion, seeAlso and versionInfo.

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: .annotation_properties() does not include rdfs: properties

jlbellier
Hello everybody,

I would like to annotate the standard annotation properties rdfs:comment , rdfs:isDefinedBy, ... with a specific annotation property to make them appear in a web page or not.

As an example :

    <rdf:Description rdf:about="http://www.w3.org/2000/01/rdf-schema#comment">
        <Occam:ClassInspectorAnnotation></Occam:ClassInspectorAnnotation>
    </rdf:Description>

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':
        print(name, cls,type(cls))

I would like then to get the ones having 'ClassInspectorAnnotation' as an annotation, so I call

getattr(cls,'ClassInspectorAnnotation')

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.

Could you please help me about this ,

Thank you in advance;

Best regards,
Jean-luc BELLIER.
Reply | Threaded
Open this post in threaded view
|

Re: .annotation_properties() does not include rdfs: properties

Jiba
Administrator
Hello,

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

with onto:
    comment.ClassInspectorAnnotation.append("value")


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

Best regards,
Jiba