Use SWRL and get 'Error creating query engine Drools'.

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Use SWRL and get 'Error creating query engine Drools'.

mary
This is my function to create ontology used OWL-API:

OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
        IRI ontologyIRI = IRI.create("http://hh/", "");
        OWLOntology ontology = manager.createOntology(ontologyIRI);
        OWLDataFactory factory = manager.getOWLDataFactory();
        PrefixManager pm = new DefaultPrefixManager(null, null, ontologyIRI.toString());
        OWLClass sr = factory.getOWLClass(":SR", pm);                                           //create class SR
        OWLClass ob = factory.getOWLClass(":Object", pm);                                   //create class Object
        OWLNamedIndividual vold = factory.getOWLNamedIndividual(":vold", pm); //create individual vold
        OWLNamedIndividual sr1 = factory.getOWLNamedIndividual(":sr1", pm);  //create individual sr1
        OWLObjectProperty hasObject = factory.getOWLObjectProperty(":hasObject", pm);
        OWLObjectPropertyAssertionAxiom propertyAssertion = factory
                .getOWLObjectPropertyAssertionAxiom(hasObject, sr1, vold);                  //create property hasObject         
       ...
        OWLClassAssertionAxiom classAssertion = factory.getOWLClassAssertionAxiom(ob, vold);
        OWLClassAssertionAxiom classAssertion1 = factory.getOWLClassAssertionAxiom(sr, sr1);
        ...
        manager.saveOntology(ontology,
                                IRI.create((new File("D:\\owl_example\\8.owl").toURI())));

This is my owl file which created by code .
<?xml version="1.0"?>
<rdf:RDF xmlns="http://hh/"
     xml:base="http://hh/"
     xmlns:hh="http://hh/"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:owl="http://www.w3.org/2002/07/owl#"
     xmlns:xml="http://www.w3.org/XML/1998/namespace"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
    <owl:Ontology rdf:about="http://hh/"/>
....

    <owl:ObjectProperty rdf:about="http://hh/hasObject"/>
...

<owl:NamedIndividual rdf:about="http://hh/sr1">
        <rdf:type rdf:resource="http://hh/SR"/>
        <hasObject rdf:resource="http://hh/vold"/>
    </owl:NamedIndividual>

   <owl:NamedIndividual rdf:about="http://hh/vold">
        <rdf:type rdf:resource="http://hh/Object"/>
    </owl:NamedIndividual>
</rdf:RDF>

This is my SWRL code:

try {
                 OWLOntologyManager ontologyManager = OWLManager.createOWLOntologyManager();
                 OWLOntology ontology = ontologyManager.loadOntologyFromOntologyDocument(file);
                 
                 SQWRLQueryEngine queryEngine = SWRLAPIFactory.createSQWRLQueryEngine(ontology);
                 SQWRLResult result = queryEngine.runSQWRLQuery("q1",
                                 "SR(?s)^hasObject(?s,vold) -> sqwrl:select(?s)");

                 if (result.next())
                         System.out.println("Name: " + result.getLiteral("x"));
                         }
        catch (OWLOntologyCreationException e) {....}

I got the error as follows:
Error starting application: Error creating query engine Drools. Exception: java.lang.NoSuchMethodError. Message: org.semanticweb.owlapi.model.OWLDocumentFormat.isPrefixOWLOntologyFormat()Z

Please help me. Thanks advance.
Reply | Threaded
Open this post in threaded view
|

Re: Use SWRL and get 'Error creating query engine Drools'.

Martin O'Connor-2

Which versions of the OWLAPI and SWRLAPI are you using?

There is a minimal example SWRLAPI application here that contains a POM defining the latest dependencies:


Martin

On May 21, 2017, at 7:47 PM, mary <[hidden email]> wrote:

This is my function to create ontology used OWL-API:

OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
       IRI ontologyIRI = IRI.create("http://hh/", "");
       OWLOntology ontology = manager.createOntology(ontologyIRI);
       OWLDataFactory factory = manager.getOWLDataFactory();
       PrefixManager pm = new DefaultPrefixManager(null, null,
ontologyIRI.toString());
       OWLClass sr = factory.getOWLClass(":SR", pm);                                          
//create class *SR*
       OWLClass ob = factory.getOWLClass(":Object", pm);                                  
//create class *Object*
       OWLNamedIndividual vold = factory.getOWLNamedIndividual(":vold",
pm); //create individual *vold*
       OWLNamedIndividual sr1 = factory.getOWLNamedIndividual(":sr1", pm);
//create individual *sr1*
       OWLObjectProperty hasObject =
factory.getOWLObjectProperty(":hasObject", pm);
       OWLObjectPropertyAssertionAxiom propertyAssertion = factory
               .getOWLObjectPropertyAssertionAxiom(hasObject, sr1, vold);                 
//create property *hasObject*          
      ...
       OWLClassAssertionAxiom classAssertion =
factory.getOWLClassAssertionAxiom(ob, vold);
       OWLClassAssertionAxiom classAssertion1 =
factory.getOWLClassAssertionAxiom(sr, sr1);
       ...
       manager.saveOntology(ontology,
IRI.create((new File("D:\\owl_example\\8.owl").toURI())));

This is my owl file which created by code .
<?xml version="1.0"?>
<rdf:RDF xmlns="http://hh/"
    xml:base="http://hh/"
    xmlns:hh="http://hh/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:owl="http://www.w3.org/2002/07/owl#"
    xmlns:xml="http://www.w3.org/XML/1998/namespace"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
   <owl:Ontology rdf:about="http://hh/"/>
....

   <owl:ObjectProperty rdf:about="http://hh/hasObject"/>
...

<owl:NamedIndividual rdf:about="http://hh/sr1">
       <rdf:type rdf:resource="http://hh/SR"/>
       <hasObject rdf:resource="http://hh/vold"/>
   </owl:NamedIndividual>

  <owl:NamedIndividual rdf:about="http://hh/vold">
       <rdf:type rdf:resource="http://hh/Object"/>
   </owl:NamedIndividual>
</rdf:RDF>

This is my SWRL code:

try {
OWLOntologyManager ontologyManager =
OWLManager.createOWLOntologyManager();
OWLOntology ontology =
ontologyManager.loadOntologyFromOntologyDocument(file);

SQWRLQueryEngine queryEngine =
SWRLAPIFactory.createSQWRLQueryEngine(ontology);
SQWRLResult result = queryEngine.runSQWRLQuery("q1",
"SR(?s)^hasObject(?s,vold) -> sqwrl:select(?s)");

if (result.next())
System.out.println("Name: " + result.getLiteral("x"));
}
catch (OWLOntologyCreationException e) {....}

I got the error as follows:
Error starting application: Error creating query engine Drools. Exception:
java.lang.NoSuchMethodError. Message:
org.semanticweb.owlapi.model.OWLDocumentFormat.isPrefixOWLOntologyFormat()Z

Please help me. Thanks advance.




--
View this message in context: http://protege-project.136.n4.nabble.com/Use-SWRL-and-get-Error-creating-query-engine-Drools-tp4668569.html
Sent from the Protege Developer mailing list archive at Nabble.com.
_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev


_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev
Reply | Threaded
Open this post in threaded view
|

Re: Use SWRL and get 'Error creating query engine Drools'.

Lorenz Buehmann
In reply to this post by mary
You used the SWRL API several times before and now you're getting this error?! What have you changed this time?

As always:

NoSuchMethodError -> different versions of the libraries, here the OWL API, i.e. the version of the SWRL API that you use depends on a different version that you use in your application code-> use Maven for dependency management

This is my function to create ontology used OWL-API:

OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
        IRI ontologyIRI = IRI.create("http://hh/", "");
        OWLOntology ontology = manager.createOntology(ontologyIRI);
        OWLDataFactory factory = manager.getOWLDataFactory();
        PrefixManager pm = new DefaultPrefixManager(null, null,
ontologyIRI.toString());
        OWLClass sr = factory.getOWLClass(":SR", pm);                                          
//create class *SR*
        OWLClass ob = factory.getOWLClass(":Object", pm);                                  
//create class *Object*
        OWLNamedIndividual vold = factory.getOWLNamedIndividual(":vold",
pm); //create individual *vold*
        OWLNamedIndividual sr1 = factory.getOWLNamedIndividual(":sr1", pm); 
//create individual *sr1*
        OWLObjectProperty hasObject =
factory.getOWLObjectProperty(":hasObject", pm);
        OWLObjectPropertyAssertionAxiom propertyAssertion = factory
                .getOWLObjectPropertyAssertionAxiom(hasObject, sr1, vold);                 
//create property *hasObject*          
       ...
        OWLClassAssertionAxiom classAssertion =
factory.getOWLClassAssertionAxiom(ob, vold);
        OWLClassAssertionAxiom classAssertion1 =
factory.getOWLClassAssertionAxiom(sr, sr1);
        ...
        manager.saveOntology(ontology,
				IRI.create((new File("D:\\owl_example\\8.owl").toURI())));

This is my owl file which created by code .
<?xml version="1.0"?>
<rdf:RDF xmlns="http://hh/"
     xml:base="http://hh/"
     xmlns:hh="http://hh/"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:owl="http://www.w3.org/2002/07/owl#"
     xmlns:xml="http://www.w3.org/XML/1998/namespace"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
    <owl:Ontology rdf:about="http://hh/"/>
....

    <owl:ObjectProperty rdf:about="http://hh/hasObject"/>
...

<owl:NamedIndividual rdf:about="http://hh/sr1">
        <rdf:type rdf:resource="http://hh/SR"/>
        <hasObject rdf:resource="http://hh/vold"/>
    </owl:NamedIndividual>

   <owl:NamedIndividual rdf:about="http://hh/vold">
        <rdf:type rdf:resource="http://hh/Object"/>
    </owl:NamedIndividual>
</rdf:RDF>

This is my SWRL code:

try {
		 OWLOntologyManager ontologyManager =
OWLManager.createOWLOntologyManager();
		 OWLOntology ontology =
ontologyManager.loadOntologyFromOntologyDocument(file);
		 
		 SQWRLQueryEngine queryEngine =
SWRLAPIFactory.createSQWRLQueryEngine(ontology);
		 SQWRLResult result = queryEngine.runSQWRLQuery("q1", 
				 "SR(?s)^hasObject(?s,vold) -> sqwrl:select(?s)");

		 if (result.next()) 
			 System.out.println("Name: " + result.getLiteral("x"));
			 }
	catch (OWLOntologyCreationException e) {....}

I got the error as follows:
Error starting application: Error creating query engine Drools. Exception:
java.lang.NoSuchMethodError. Message:
org.semanticweb.owlapi.model.OWLDocumentFormat.isPrefixOWLOntologyFormat()Z

Please help me. Thanks advance.




--
View this message in context: http://protege-project.136.n4.nabble.com/Use-SWRL-and-get-Error-creating-query-engine-Drools-tp4668569.html
Sent from the Protege Developer mailing list archive at Nabble.com.
_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev

-- 
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center

_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev
Reply | Threaded
Open this post in threaded view
|

Re: Use SWRL and get 'Error creating query engine Drools'.

mary
In reply to this post by Martin O'Connor-2
I use jdk 1.8  OWL-API 5.1 and SWRLapi-1.07.
I download the swrl project and use mvn build it.
I also unzip jar swrltab-plugin-1.0.7,swrltab-2.0.0-jar-with-dependencies,swrlapi-example-2.0.0-jar-with-dependencies. And add jar under /lib.
Reply | Threaded
Open this post in threaded view
|

Re: Use SWRL and get 'Error creating query engine Drools'.

Lorenz Buehmann
I don't understand why you need the Jars from the SWRL Tab plugin. You only need SWRL API + OWL API.

I use jdk 1.8  OWL-API 5.1 and SWRLapi-1.07.
I download the swrl project and use mvn build it.
I also unzip jar
swrltab-plugin-1.0.7,swrltab-2.0.0-jar-with-dependencies,swrlapi-example-2.0.0-jar-with-dependencies.
And add jar under /lib.
<http://protege-project.136.n4.nabble.com/file/n4668573/swrl-jar.png> 



--
View this message in context: http://protege-project.136.n4.nabble.com/Use-SWRL-and-get-Error-creating-query-engine-Drools-tp4668569p4668573.html
Sent from the Protege Developer mailing list archive at Nabble.com.
_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev


-- 
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center

_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev
Reply | Threaded
Open this post in threaded view
|

Re: Use SWRL and get 'Error creating query engine Drools'.

Martin O'Connor-2
In reply to this post by mary

The SWRLAPI uses the 4.2.7 version of the OWLAPI. (FYI, the 5+ version of the OWLAPI is not backwards compatible with the 4.x.x. version; there are no plans to port the SWRLAPI to the 5+ version of the OWLAPI.)

I can’t fully understand your questions below. By ‘exit’ do you mean ‘exist’?

Can you post the ontology?

Martin

> On May 22, 2017, at 1:14 AM, mary <[hidden email]> wrote:
>
> I remove and add all external jar again,and this time got another error.
> SQWRLResult result = queryEngine.runSQWRLQuery("q1",
> "SR(?s)^hasObject(?s,vold) -> sqwrl:select(?s)");
> if the individual  *vold* is not  exit in owl file. There is no error.
>
> Then,changing to another individual which is exit in owl file like /data.
> SQWRLResult result = queryEngine.runSQWRLQuery("q1",
> "SR(?s)^hasObject(?s,/data) -> sqwrl:select(?s)");
> the individual* /data* is exit in owl file, got error as follows:
>
> *Error running SWRL rule or SQWRL query: invalid column name x*
> Please help me.Thanks.
>
>
>
> --
> View this message in context: http://protege-project.136.n4.nabble.com/Use-SWRL-and-get-Error-creating-query-engine-Drools-tp4668569p4668575.html
> Sent from the Protege Developer mailing list archive at Nabble.com.
> _______________________________________________
> protege-dev mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-dev

_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev
Reply | Threaded
Open this post in threaded view
|

Re: Use SWRL and get 'Error creating query engine Drools'.

Lorenz Buehmann
In reply to this post by mary
Please check spelling next time, it is called "exists"

And then, hasObject is what? an object property I guess? that means the second argument has to be an individual in your ontology. Is there an individual "vold"? And your sure there is an individual "/data"? Why the slash here? Your naming convention is confusing.

I remove and add all external jar again,and this time got another error.
SQWRLResult result = queryEngine.runSQWRLQuery("q1", 
			 "SR(?s)^hasObject(?s,vold) -> sqwrl:select(?s)");
if the individual  *vold* is not  exit in owl file. There is no error.

Then,changing to another individual which is exit in owl file like /data.
SQWRLResult result = queryEngine.runSQWRLQuery("q1", 
			 "SR(?s)^hasObject(?s,/data) -> sqwrl:select(?s)");
the individual* /data* is exit in owl file, got error as follows:

*Error running SWRL rule or SQWRL query: invalid column name x*
Please help me.Thanks.



--
View this message in context: http://protege-project.136.n4.nabble.com/Use-SWRL-and-get-Error-creating-query-engine-Drools-tp4668569p4668575.html
Sent from the Protege Developer mailing list archive at Nabble.com.
_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev

-- 
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center

_______________________________________________
protege-dev mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-dev