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.
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, eg 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.xx ) 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 )
]
]
)
]
] .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.