I am trying to load an ontology from a Jena model using OWL API, but most of the axioms are appearing as annotations.
The ontology in Turtle is shown below. I use a Jena model to store it. NB: The ontology below is not correct, as mentioned in answers down
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
<http://example.com/minimalDecoupling>
a "http://www.w3.org/2002/07/owl#DatatypeProperty" ;
rdfs:label "minimal decoupling" .
<http://example.com/frequency>
a "http://www.w3.org/2002/07/owl#DatatypeProperty" ;
rdfs:label "frequency" .
<http://example.com/voltage>
a "http://www.w3.org/2002/07/owl#DatatypeProperty" ;
rdfs:label "Voltage" .
<http://example.com/powerConsumed>
a "http://www.w3.org/2002/07/owl#DatatypeProperty" ;
rdfs:label "power consumed" .
<http://example.com/installation>
a "http://www.w3.org/2002/07/owl#DatatypeProperty" ;
rdfs:label "installation" .
<http://example.com/Device>
a "http://www.w3.org/2002/07/owl#Class" ;
rdfs:label "device" .
<http://example.com/dimension>
a "http://www.w3.org/2002/07/owl#DatatypeProperty" ;
rdfs:label "dimension" .
<http://example.com/>
a "http://www.w3.org/2002/07/owl#Ontology" .
Suppose that the above ontology is stored in the Jena model ontologyGraph
, I am using the code below to load the Jena model as an OWL ontology.
OWLOntology ontology = ontologyManager.
loadOntologyFromOntologyDocument
(new ByteArrayInputStream(Ontology.toTurtle(ontologyGraph).getBytes()));
The toTurtle
method is shown below:
public static String toTurtle(Model ontologyGraph){
StringWriter out = new StringWriter();
ontologyGraph.write(out,"TTL");
return out.toString();
}
However, as we see in the output below, the axioms from the ontology are appearing annotation axiom:
Ontology(OntologyID(Anonymous-2)) [Axioms: 15 Logical Axioms: 0] First 20 axioms: {AnnotationAssertion(rdfs:label http://example.com/powerConsumed "power consumed") AnnotationAssertion(rdfs:label http://example.com/minimalDecoupling "minimal decoupling") AnnotationAssertion(rdf:type http://example.com/ "http://www.w3.org/2002/07/owl#Ontology") AnnotationAssertion(rdfs:label http://example.com/dimension "dimension") AnnotationAssertion(rdf:type http://example.com/dimension "http://www.w3.org/2002/07/owl#DatatypeProperty") AnnotationAssertion(rdf:type http://example.com/voltage "http://www.w3.org/2002/07/owl#DatatypeProperty") AnnotationAssertion(rdf:type http://example.com/Device "http://www.w3.org/2002/07/owl#Class") AnnotationAssertion(rdfs:label http://example.com/installation "installation") AnnotationAssertion(rdfs:label http://example.com/voltage "Voltage") AnnotationAssertion(rdf:type http://example.com/minimalDecoupling "http://www.w3.org/2002/07/owl#DatatypeProperty") AnnotationAssertion(rdf:type http://example.com/frequency "http://www.w3.org/2002/07/owl#DatatypeProperty") AnnotationAssertion(rdfs:label http://example.com/Device "device") AnnotationAssertion(rdf:type http://example.com/powerConsumed "http://www.w3.org/2002/07/owl#DatatypeProperty") AnnotationAssertion(rdfs:label http://example.com/frequency "frequency") AnnotationAssertion(rdf:type http://example.com/installation "http://www.w3.org/2002/07/owl#DatatypeProperty") }
My questions are:
- why are all the axioms appearing as annotations ?
- Is it possible to directly load a Jena model as an OWL ontology using OWL API without having to pass through Turtle ?