protegeproject / swrlapi

Java API for working with the SWRL rule and SQWRL query languages
Other
99 stars 40 forks source link

org.semanticweb.owlapi.model.OWLDocumentFormat.isPrefixOWLOntologyFormat()Z #48

Closed viniciusjns closed 5 years ago

viniciusjns commented 6 years ago

I'm trying to infer some rules of an ontology that a created in Protégé, but I'm getting this error:

Exception in thread "main" org.swrlapi.exceptions.SWRLRuleEngineException: Error creating query engine Drools. Exception: java.lang.NoSuchMethodError. Message: org.semanticweb.owlapi.model.OWLDocumentFormat.isPrefixOWLOntologyFormat()Z at org.swrlapi.factory.DefaultSWRLRuleAndQueryEngineFactory.createSQWRLQueryEngine(DefaultSWRLRuleAndQueryEngineFactory.java:111) at org.swrlapi.factory.DefaultSWRLRuleAndQueryEngineFactory.createSQWRLQueryEngine(DefaultSWRLRuleAndQueryEngineFactory.java:82) at org.swrlapi.factory.SWRLAPIFactory.createSQWRLQueryEngine(SWRLAPIFactory.java:61) at owlapi.OWLAPIChange.main(OWLAPIChange.java:86) Caused by: java.lang.NoSuchMethodError: org.semanticweb.owlapi.model.OWLDocumentFormat.isPrefixOWLOntologyFormat()Z at org.swrlapi.factory.DefaultIRIResolver.updatePrefixes(DefaultIRIResolver.java:165) at org.swrlapi.factory.DefaultSWRLAPIOWLOntology.(DefaultSWRLAPIOWLOntology.java:163) at org.swrlapi.factory.SWRLAPIInternalFactory.createSWRLAPIOntology(SWRLAPIInternalFactory.java:266) at org.swrlapi.factory.DefaultSWRLRuleAndQueryEngineFactory.createSQWRLQueryEngine(DefaultSWRLRuleAndQueryEngineFactory.java:92) ... 3 more

Here is the code of loading my ontology and creating the SWRLRuleEngine

OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
File file = new File("C:\\Users\\Vinicius\\Documents\\ontology_smell.owl");
if (!file.exists())
    file.createNewFile();
OWLOntology ontology = manager.loadOntologyFromOntologyDocument(file);
SWRLRuleEngine swrlRuleEngine = SWRLAPIFactory.createSWRLRuleEngine(ontology);
swrlRuleEngine.infer();

What am I doing wrong?

ontology_smell.owl.txt

viniciusjns commented 6 years ago

Here's the pom.xml

<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0
<groupId>owlapi.tutorial</groupId>
<artifactId>owlapi.tutorial</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
</build>
<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
    </dependency>
    <dependency>
        <groupId>net.sourceforge.owlapi</groupId>
        <artifactId>owlapi-distribution</artifactId>
        <version>5.0.0</version>
    </dependency>
    <dependency>
        <groupId>net.sourceforge.owlapi</groupId>
        <artifactId>org.semanticweb.hermit</artifactId>
        <version>1.4.1.513</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>edu.stanford.swrl</groupId>
        <artifactId>swrlapi</artifactId>
        <version>2.0.5</version>
    </dependency>
    <dependency>
        <groupId>edu.stanford.swrl</groupId>
        <artifactId>swrlapi-drools-engine</artifactId>
        <version>2.0.5</version>
    </dependency>
</dependencies>

martinjoconnor commented 6 years ago

The SWRLAPI does not work with version 5+ of the OWLAPI.

Take a look at this POM to see its version dependencies:

https://github.com/protegeproject/swrlapi-parent/blob/master/pom.xml