How to use Pellet reasoner in OWL API

396 Views Asked by At

I have an Ontology which have some SWRL rules (created using Protege). I am using OWL API to manipulate the ontology and using JENA API for SPARQL Queries. I need to reason this ontology using Pellet (As pellet supports SWRL and i have sed the reasoner inside protege). I saw some examples at https://github.com/ignazio1977/pellet/blob/master/examples/src/main/java/org/mindswap/pellet/examples/OWLAPIi am using the following dependency

<dependency>
    <groupId>com.github.ansell.pellet</groupId>
    <artifactId>pellet-owlapiv3</artifactId>
    <version>2.3.6-ansell</version>
</dependency>

The code is as follows

OWLOntologyManager man = OWLManager.createOWLOntologyManager();
File file = new File("C:\\Protege-5.5.0\\ContextModellingJAVA.owl");
// Loading an Ontology from file
OWLOntology o = man.loadOntologyFromOntologyDocument(file);

PelletReasoner reasoner = PelletReasonerFactory.getInstance().createReasoner(o);
System.out.println("done.");

When I run this I am getting the following error

Exception in thread "main" java.lang.NoSuchMethodError: 'org.semanticweb.owlapi.model.OWLPropertyExpression org.semanticweb.owlapi.model.OWLObjectPropertyDomainAxiom.getProperty()'
    at com.clarkparsia.pellet.owlapiv3.PelletVisitor.visit(PelletVisitor.java:945)
    at org.semanticweb.owlapi.model.OWLObjectPropertyDomainAxiom.accept(OWLObjectPropertyDomainAxiom.java:36)
    at com.clarkparsia.pellet.owlapiv3.PelletVisitor.visit(PelletVisitor.java:699)
    at org.semanticweb.owlapi.model.OWLOntology.accept(OWLOntology.java:519)
    at com.clarkparsia.pellet.owlapiv3.PelletReasoner.refresh(PelletReasoner.java:967)
    at com.clarkparsia.pellet.owlapiv3.PelletReasoner.<init>(PelletReasoner.java:345)
    at com.clarkparsia.pellet.owlapiv3.PelletReasoner.<init>(PelletReasoner.java:304)
    at com.clarkparsia.pellet.owlapiv3.PelletReasonerFactory.createReasoner(PelletReasonerFactory.java:71)
    at ContextModelling.main(ContextModelling.java:166)



Can anyone please help me solve the error. Thanks in advace
2

There are 2 best solutions below

0
On

The Ansell dependency is a build of owlapi version 3, the pellet project you reference uses owlapi 4. The error you're seeing depends on a version conflict between owlapi 3 and 4.

Remove the Ansell dependency from your pom and only use the pellet dependency, it will transitively pull in the right owlapi build.

This is the latest build of pellet I've released - fork of the original repository, works with protégé as well. Openllet is another fork that has been more actively maintained.

<dependency>
<groupId>net.sourceforge.owlapi</groupId>
<artifactId>pellet-owlapi-ignazio1977</artifactId>
<version>2.4.0-ignazio1977</version>
</dependency>
0
On

pellet-owlapi worked but as suggested by @Ignazio I tried the Openllet with the following dependency.

<dependency>
    <groupId>com.github.galigator.openllet</groupId>
    <artifactId>openllet-owlapi</artifactId>
    <version>2.6.5</version>
</dependency>

thank you