rdfs:comment annotation

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

rdfs:comment annotation

Daniela
This post was updated on .
Hi,
I'm using the DBPedia ontology and iterating over the classes with the classes() method. I want to get the rdfs:comment annotation and tried like this:

    onto = get_ontology("dbpedia.owl").load()
    for oclass in onto.classes():
        print(oclass.comment)

But this just prints an empty list despite the ontology containing several rdfs:comment annotations. I tried with other ontologies and this approach works. Do you know what could be happening with the dbpedia ontology?

Here's a snippet from the dbpedia ontology:
  <owl:Class rdf:about="http://dbpedia.org/ontology/SongWriter">
    <rdfs:label xml:lang="en">Songwriter</rdfs:label>
    <rdfs:label xml:lang="fr">Auteur-Compositeur</rdfs:label>
    <rdfs:comment xml:lang="en">a person who writes songs.</rdfs:comment>
    <rdfs:subClassOf rdf:resource="http://dbpedia.org/ontology/Writer"/>
    <prov:wasDerivedFrom rdf:resource="http://mappings.dbpedia.org/index.php/OntologyClass:SongWriter"/>
  </owl:Class>

How should I access the rdfs:comment annotation if not like this?
Reply | Threaded
Open this post in threaded view
|

Re: rdfs:comment annotation

Jiba
Administrator
Hi,

I've investigated the problem. Actually, DBPedia uses the standard RDFS comment annotation for commenting class, but it also defines its own "comment" property. Consequently, Owlready use this DBPedia's comment property when using the ".comment" attribut for example :

>>> onto = get_ontology("dbpedia_2016-10.owl").load()
>>> onto.SongWriter.comment  # DBPedia's comment
[]


To force the use of the RDFS comment, you can use the alternative property[entity] syntax as follows:

>>> comment[onto.SongWriter] # RDFS comment
['a person who writes songs.', 'een persoon die de muziek en/of de tekst voor populaire muzieknummers schrijft.']


Or you can also override the property used by ".comment" as follows:
>>> default_world._props["comment"] = comment
>>> onto.SongWriter.comment  # RDFS comment now!
['a person who writes songs.', 'een persoon die de muziek en/of de tekst voor populaire muzieknummers schrijft.']

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: rdfs:comment annotation

Daniela
Hi,
Sorry for the delay in replying, only now I got around to test it again. Both methods worked to get around the problem, thanks.