Using TrOWL with OWLAPI

TrOWL supports the OWLReasoner interface from the OWL API. TrWOL has native support for working with objects such as ontologies and class expression from the OWL API 3.2.X.

To start, you could unzip the downloaded zip file for TrOWL and create a new Java project in Eclipse based on the unzipped folder. There is a sample java file titled TrOWLDemo.java and a sample owl file titled food.owl in the folder.

After adding TrOWLCore.jar and owlapi3.jar to your build path, you can now instantiate TrOWL in your java program by creating an instance of the Reasoner class. Currently TrOWL provides direct access to two different versions of the REL reasoner component. One is for OWL 2 EL reasoning and the other is for OWL 2 DL reasoning via syntactic approximation. To initialise a DL reasoner, first import the eu.trowl.owlapi3.rel.reasoner.dl.RELReasonerFactory/RELReasoner packages. The following code shows how to loads an ontology, creates a reasoner object and check whether the ontology is consistent.

IRI physicalIRI = IRI.create(“fileName”);
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLOntology ontology = manager.loadOntologyFromOntologyDocument(physicalIRI);
RELReasonerFactory relfactory = new RELReasonerFactory();
RELReasoner reasoner = relfactory.createReasoner(ontology);
System.out.println("Check consistency: " + reasoner.isConsistent());

To initialise an EL reasoner, the only difference is to import the eu.trowl.owlapi3.rel.reasoner.el.RELReasonerFactory/RELReasoner packages.

More details can be found in the TrOWLDemo.java file (in the release).