I have annotated the relationship described below
TV subClassof : Restriction {hasFeature some PowerConsumption} ::: @isNegative=true.
The TV class has a Object property called hasFeature
with values in class PowerConsumption
. The annotation is applied to this property relation. The OWL file gets added with the following axiom to represent the added annotation. How can I retrieve this axiom and get the annotation value of isNegative
using Jena?
<owl:Axiom>
<isNegative>true</isNegative>
<owl:annotatedSource rdf:resource="&product_ontolology;TV"/>
<owl:annotatedProperty rdf:resource="&rdfs;subClassOf"/>
<owl:annotatedTarget>
<owl:Restriction>
<owl:onProperty rdf:resource="&product_ontolology;hasFeature"/>
<owl:someValuesFrom rdf:resource="&product_ontolology;PowerConsumption"/>
</owl:Restriction>
</owl:annotatedTarget>
</owl:Axiom>
Jena is an RDF-centric API, although it provides some abstraction in the form of OntModel. Even so, OntModels don't provide a convenient way to access the axioms and to annotate them. You might have better luck using the a more OWL-centric API, such as the aptly named OWL API.
Nonetheless, OWL can be serialized as RDF, and while there may be pitfalls (because there might be variation in the way that an OWL ontology can be serialized into RDF), you can probably get the sort of results you want. Here's Java code that loads a small portion of your ontology, finds the
owl:Axiom
s inside, and determines which of their properties are annotation properties.The output shows the statement that you are interested in.
Here's the small OWL ontology I used: