Skip to content

owlcs/ont-api

Repository files navigation

ONT-API (ver. 3.x.x)

Summary

ONT-API is an RDF-centric Java library to work with OWL2.

For more info about the library see the project wiki.

Dependencies

Requirements

  • Java 11+

License

  • Apache License Version 2.0
  • GNU LGPL Version 3.0

Example

import com.github.owlcs.ontapi.OntManagers;
import com.github.owlcs.ontapi.Ontology;
import com.github.owlcs.ontapi.jena.vocabulary.OWL;
import org.apache.jena.rdf.model.Model;
import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owlapi.model.OWLDataFactory;

public class Examples {
    public static void main(String... args) {
        String iri = "http://example.com";
        OWLDataFactory df = OntManagers.getDataFactory();

        Ontology owl = OntManagers.createManager().createOntology(IRI.create(iri));
        owl.addAxiom(df.getOWLDeclarationAxiom(df.getOWLClass(iri + "#Class1")));

        Model jena = owl.asGraphModel();
        jena.createResource(iri + "#Class2", OWL.Class);

        owl.axioms().forEach(System.out::println);
        jena.write(System.out, "ttl");
    }
}