Skip to content

sszuev/jena-owl2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Apache Jena OWL2 Model


NOTE: This library has been integrated into Apache Jena starting from version 5.1.0 (:jena-ontapi). The current repository will remain available for compatibility with Apache Jena 4.x.x.


Summary

This is enhanced Apache Jena Inference RDF Model with OWL2 support. The original code is taken from ONT-API.

Motivation

com.github.owlcs.ontapi.jena.model.OntModel covers OWL2 syntax but not inference and OWL profiles.
org.apache.jena.ontology.OntModel supports inference, but only follows OWL1 specification.

This project closes this gap by providing a fully functional ontology RDF model for working with OWL2.

Major components

  • OntModel - the main interface to work with OWL2 & OWL1 & RDFS ontologies
  • OntModelFactory - factory for creating different OntModel types
  • GraphRepository - graph store accessor
  • OntSpecification - encapsulates ReasonerFactory, OntConfig, OntPersonality
  • UnionGraph - a Graph implementation with support hierarchy
  • OntModelConfig - model configuration, defines what a model can do and what it cannot do
  • OntPersonality - a configuration class to conduct Jena's polymorphism for OntObjects

Supported specifications

  • OWL2 DL & Full: NO_INF, RULES_INF, RDFS_INF, TRANS_INF + BUILTIN_INF (default)
  • OWL2 EL: NO_INF, RULES_INF, RDFS_INF, TRANS_INF
  • OWL2 QL: NO_INF, RULES_INF, RDFS_INF, TRANS_INF
  • OWL2 RL: NO_INF, RULES_INF, RDFS_INF, TRANS_INF
  • OWL1 DL & Full: NO_INF, RULES_INF, RDFS_INF, TRANS_INF, MICRO_RULES, MINI_RULES
  • OWL1 Lite: NO_INF, RULES_INF, RDFS_INF, TRANS_INF
  • RDFS: NO_INF, RDFS_INF, TRANS_INF

Example

GraphRepository repository = GraphRepository.createGraphDocumentRepositoryMem();

OntModel m = OntModelFactory.createModel(OntSpecification.OWL2_DL_MEM_BUILTIN_INF, repository)
        .setNsPrefixes(OntModelFactory.STANDARD);

m.setID("ont").setVersionIRI("ont#v1");

OntObjectProperty p = m.createObjectProperty("p");
OntClass a = m.createOntClass("a");
OntIndividual i = a.createIndividual("i");
OntClass b = m.createOntClass("b")
        .addSuperClass(m.createObjectIntersectionOf(a, m.createObjectHasValue(p, i)));

m.ontObjects(OntClass.class).forEach(System.out::println);
m.ontObjects(OntIndividual.class).forEach(System.out::println);

m.write(System.out, "ttl");

Available via jitpack

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>com.github.sszuev</groupId>
        <artifactId>jena-owl2</artifactId>
        <version>{{latest-version}}</version>
    </dependency>
</dependencies>

Apache License Version 2.0