I have an ontology
<owl:ObjectProperty rdf:about="http://purl.obolibrary.org/obo/BFO_0000050">
<owl:inverseOf rdf:resource="http://purl.obolibrary.org/obo/BFO_0000051"/>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#TransitiveProperty"/>
<oboInOwl:hasDbXref rdf:datatype="http://www.w3.org/2001/XMLSchema#string">BFO:0000050</oboInOwl:hasDbXref>
<oboInOwl:hasOBONamespace rdf:datatype="http://www.w3.org/2001/XMLSchema#string">external</oboInOwl:hasOBONamespace>
<oboInOwl:id rdf:datatype="http://www.w3.org/2001/XMLSchema#string">part_of</oboInOwl:id>
<oboInOwl:shorthand rdf:datatype="http://www.w3.org/2001/XMLSchema#string">part_of</oboInOwl:shorthand>
<rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">part of</rdfs:label>
</owl:ObjectProperty>
I'm trying to extract all the ObjectProperties,
for (OWLObjectProperty obp : ont.getObjectPropertiesInSignature()){
System.out.println(obp.toString());
}
this will print the name of ObjectProperty, e.g. http://purl.obolibrary.org/obo/BFO_0000050.
I wonder how to get the rdfs:label, e.g. part of
The
rdfs:label
in OWL is an annotation. To get thelabel
you must query for the annotation of the objectProperty you want.To display all annotations of an ontology you can do something like that :
getObjectPropertiesInSignature()
is deprecated in the modern (more than one year) version of owlapi (5). So please considere using thestream
versionobjectPropertiesInSignature
of java-8 . java-9 have been release few days ago, so it is a good time to learn thestream
functionnality.NB: the annotations are almost free, but OWL2 have put some more standardisation on it, so there is annotations with 'predefined semantics'.