May I know if Apahe JENA supports OWL 2 syntax in Java? It does mentioned that in the documentation (https://jena.apache.org/documentation/ontology/) it only provide limited cardinality restrictions. I would like to confirm this from the experts.
-
The experts would be the people who wrote the documentation that confirms the answer your looking for :) – Flightdoc5242 Jan 05 '19 at 07:17
-
1No, it doesn't support full OWL 2. And yes, I can confirm the documentation. It's mostly up to date. By the way, you could still add the RDF triples by hand to build the OWL constructs, you just don't have the convenience API methods in Jena. Or you use OWL API given that the OWL is made of axioms and not RDF triples. – UninformedUser Jan 05 '19 at 08:23
1 Answers
Apache Jena does not support OWL2, only OWL11 through org.apache.jena.ontology.OntModel interface. See also documentation.
But you still can work with OWL2 in Jena using some external jena-based APIs and tools, e.g. ONT-API, that is OWL-API-api(v5) impl over Jena.
In ONT-API there are two main OWL2 view of data, which encapsulate the same RDF Graph: com.github.owlcs.ontapi.jena.model.OntModel
and com.github.owlcs.ontapi.Ontology
(in older versions (ONT-API:v1.x.x) these classes have names ru.avicomp.ontapi.jena.model.OntGraphModel
and ru.avicomp.ontapi.OntologyModel
respectively).
The com.github.owlcs.ontapi.jena.model.OntModel view is a full analogue of Jena org.apache.jena.ontology.OntModel
, it is the facility to work with triples.
And the com.github.owlcs.ontapi.Ontology view is an extended org.semanticweb.owlapi.model.OWLOntology
, the facility to work with axiomatic data, that is backed by the com.github.owlcs.ontapi.jena.model.OntModel
view and vice-versa.
For example, the following snippet:
String uri = "https://stackoverflow.com/questions/54049750";
String ns = uri + "#";
OntModel m = OntModelFactory.createModel()
.setNsPrefixes(OntModelFactory.STANDARD).setNsPrefix("q", ns);
m.setID(uri);
OntClass c = m.createOntClass(ns + "c");
OntObjectProperty p = m.createObjectProperty(ns + "p");
OntIndividual i = c.createIndividual(ns + "i");
m.createObjectComplementOf(m.createObjectUnionOf(c, m.getOWLThing(),
m.createObjectSomeValuesFrom(p, m.createObjectOneOf(i))));
m.write(System.out, "ttl");
will produce the following ontology:
@prefix q: <https://stackoverflow.com/questions/54049750#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
<https://stackoverflow.com/questions/54049750>
a owl:Ontology .
q:c a owl:Class .
q:p a owl:ObjectProperty .
q:i a owl:NamedIndividual , q:c .
[ a owl:Class ;
owl:complementOf [ a owl:Class ;
owl:unionOf ( q:c owl:Thing
[ a owl:Restriction ;
owl:onProperty q:p ;
owl:someValuesFrom [ a owl:Class ;
owl:oneOf ( q:i )
]
]
)
]
] .

- 835
- 1
- 6
- 18
-
Thank you very much for the lengthy explanation. I really appreciate it. Thank you again. – MuhammadMahmud Jan 06 '19 at 09:10