inference engine and rules

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

inference engine and rules

Talya
Hello and Happy new year
I have created several SWRL rules in my ontology. Then I have developed a Java application and I interact with my ontology using SQWRL and SPARQL.
In fact, I find several problems and unfortunately I don't know how to resolve them. I hope that you can help to answer these questions:
How may I control my inference engine (I used Drools engine)
How may I indicates which rules are triggered
I hope that you understand my need thanks and good day
Reply | Threaded
Open this post in threaded view
|

Re: inference engine and rules

Lorenz B.
What's the relationship to Protege?

> Hello and Happy new year
> I have created several SWRL rules in my ontology. Then I have developed a
> Java application and I interact with my ontology using SQWRL and SPARQL.
> In fact, I find several problems and unfortunately I don't know how to
> resolve them. I hope that you can help to answer these questions:
> How may I control my inference engine (I used Drools engine)
> How may I indicates which rules are triggered
> I hope that you understand my need thanks and good day
>
>
>
>
> --
> View this message in context: http://protege-project.136.n4.nabble.com/inference-engine-and-rules-tp4667237.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: inference engine and rules

Talya
Hello,
Really, I don't have an answer.
what I know that I used protege to create and execute my SWRL rules based on Drools engine. and then through the Java application I just interact with my ontology with SPARQL queries.
For example, I create 10 SWRL rules. How may I indicate that I want to execute rule n°5 and not others.
through Java code how may I do this.
I asked my question in protege because as a developer, you have created several plug-ins (SWRLAPI, OWLAPI, etc.) and language (SQWRL, SPARQL, SWRL,) and you have proposed some Java code for example how to interact with ontology based on reasoner.
So I think maybe I can use these plugins and language for my need. but I succeed only to execute SPARQL or SQWRL rules.
but, If this is not related to protege so please help me with another group or forum.
Thanks
Reply | Threaded
Open this post in threaded view
|

Re: inference engine and rules

Lorenz B.
It is not clear HOW you interact with the ontology.

OWL API? Which version?
Which reasoner? Which version?
If Drools, how? Which API? Show the relevant code.
How to you use SPARQL on an OWL ontology? And why?
WHAT does not work as expected?

If you're OWL ontology contains 10 SWRL rules, then ALL rules will be used during inference. There is no way to focus on a single rule, as far as I know. If you have the rules separately, you would have to use a single rule and compute all the inferences again. But without seeing code and knowing about the used APIs, no way to give more details.

You see, you provided almost no information...

Hello, 
Really, I don't have an answer. 
what I know that I used protege to create and execute my SWRL rules based on
Drools engine. and then through the Java application I just interact with my
ontology with SPARQL queries. 
For example, I create 10 SWRL rules. How may I indicate that I want to
execute rule n°5 and not others. 
through Java code how may I do this. 
I asked my question in protege because as a developer, you have created
several plug-ins (SWRLAPI, OWLAPI, etc.) and language (SQWRL, SPARQL, SWRL,)
and you have proposed some Java code for example how to interact with
ontology based on reasoner. 
So I think maybe I can use these plugins and language for my need. but I
succeed only to execute SPARQL or SQWRL rules. 
but, If this is not related to protege so please help me with another group
or forum. 
Thanks 




--
View this message in context: http://protege-project.136.n4.nabble.com/inference-engine-and-rules-tp4667237p4667239.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: inference engine and rules

Talya
Sorry because maybe I ask a not a clear question for you.
I'm not an expert in protege and ontology. I'm a beginner, so what I know exactly is:
after creating an ontology and insert some individuals I create some SWRL rules in SWRLTAB in protege and execute them with drools that is integrated in protege. Then I created a Java application. I find the only manner to interact with ontology is through a query language (SPARQL and SQWRL). Here I found that this manner is not intelligent.
See this scenario.
through my Java application I add student (Martin, who has noted 16 in English) in my ontology. here I want to know the mention of Martin that I add him recently.
my ontology contains a swrl rule which is well executed and give me a correct answer for the unregistered student. Martin I have added it recently, so when I want to execute this rule another time I should go to protege and SWRLTAB and execute it. which I found it a bit boring and intelligent. And normal users do not know protege and ontology and....
he just adds a student to the base and then want to know the mention of him.
student(?s) ^englishscore(?sc)^hasscore(?s,?sc)^hasvalue(?sc,?m)^swrlb:greaterThan(?m,10)->has-mention(?s,verygood).
this is an example of sqwrl:
 
package these;
import java.io.IOException;


import javax.swing.JOptionPane;

import org.semanticweb.owlapi.apibinding.OWLManager;
import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLOntologyCreationException;
import org.semanticweb.owlapi.model.OWLOntologyManager;
import org.swrlapi.factory.SWRLAPIFactory;
import org.swrlapi.parser.SWRLParseException;
import org.swrlapi.sqwrl.SQWRLQueryEngine;
import org.swrlapi.sqwrl.SQWRLResult;
import org.swrlapi.sqwrl.exceptions.SQWRLException;

public class Interrogations {

        private static String Message ="";

        //private final static String fileOwl = "D:/university.owl";
                public static void main (String[] args) {
                                try {
                                       
            IRI documentIRI = IRI.create("file:///D:/personne.owl");
    OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
        OWLOntology ontology = manager.loadOntologyFromOntologyDocument(documentIRI);
     
                 SQWRLQueryEngine queryEngine = SWRLAPIFactory.createSQWRLQueryEngine(ontology);
               
         SQWRLResult result = queryEngine.runSQWRLQuery("q1","student(Martin) ^ mention(?m)^has-mention(Martin,?m)->sqwrl:select(?m) ");
          while (result.next()) {
         
          System.out.println("Mention: " + result.getNamedIndividual("m"));
          Message+=result.getNamedIndividual("m").toString()+result.getNamedIndividual("p").toString()+"\n";
          //Dispalynig.addRowTable(new Object[]{ result.getNamedIndividual("m"), result.getNamedIndividual("p")});
         
                 }
          JOptionPane jop1 = new JOptionPane();
            jop1.showMessageDialog(null, Message,  null, JOptionPane.WARNING_MESSAGE);
                                }
        catch (OWLOntologyCreationException e) {
              System.err.println("Error creating OWL ontology: " + e.getMessage());
              System.exit(-1);
            } catch (SWRLParseException e) {
              System.err.println("Error parsing SQWRL query: " + e.getMessage());
              System.exit(-1);
            } catch (SQWRLException e) {
              System.err.println("Error running SQWRL query: " + e.getMessage());
              System.exit(-1);
            } catch (RuntimeException e) {
              System.err.println("Error starting application: " + e.getMessage());
              System.exit(-1);
            }

        }
       
       
       
       
}


if you have any idea to help me please tell me it
Thank you very much

Reply | Threaded
Open this post in threaded view
|

Re: inference engine and rules

Lorenz B.
Ok, so far you have code that checks via SQWRL query for an existing mention of Martin. And what doesn't work now?

Sorry because maybe I ask a not a clear question for you. 
I'm not an expert in protege and ontology. I'm a beginner, so what I know
exactly is: 
after creating an ontology and insert some individuals I create some SWRL
rules in SWRLTAB in protege and execute them with drools that is integrated
in protege. Then I created a Java application. I find the only manner to
interact with ontology is through a query language (SPARQL and SQWRL). Here
I found that this manner is not intelligent. 
See this scenario. 
through my Java application I add student (Martin, who has noted 16 in
English) in my ontology. here I want to know the mention of Martin that I
add him recently.
my ontology contains a swrl rule which is well executed and give me a
correct answer for the unregistered student. Martin I have added it
recently, so when I want to execute this rule another time I should go to
protege and SWRLTAB and execute it. which I found it a bit boring and
intelligent. And normal users do not know protege and ontology and.... 
he just adds a student to the base and then want to know the mention of him. 
student(?s)
^englishscore(?sc)^hasscore(?s,?sc)^hasvalue(?sc,?m)^swrlb:greaterThan(?m,10)->has-mention(?s,verygood). 
this is an example of sqwrl:
 
*package these;
import java.io.IOException;


import javax.swing.JOptionPane;

import org.semanticweb.owlapi.apibinding.OWLManager;
import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLOntologyCreationException;
import org.semanticweb.owlapi.model.OWLOntologyManager;
import org.swrlapi.factory.SWRLAPIFactory;
import org.swrlapi.parser.SWRLParseException;
import org.swrlapi.sqwrl.SQWRLQueryEngine;
import org.swrlapi.sqwrl.SQWRLResult;
import org.swrlapi.sqwrl.exceptions.SQWRLException;

public class Interrogations {

	private static String Message ="";

	//private final static String fileOwl = "D:/university.owl";
		public static void main (String[] args) {
				try {
					
	    	IRI documentIRI = IRI.create("file:///D:/personne.owl");
    	OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
        OWLOntology ontology =
manager.loadOntologyFromOntologyDocument(documentIRI);
      
		 SQWRLQueryEngine queryEngine =
SWRLAPIFactory.createSQWRLQueryEngine(ontology);
		
	 SQWRLResult result = queryEngine.runSQWRLQuery("q1","student(Martin) ^
mention(?m)^has-mention(Martin,?m)->sqwrl:select(?m) ");
	 		 while (result.next()) {
	 			
	 			System.out.println("Mention: " + result.getNamedIndividual("m"));
	 		
Message+=result.getNamedIndividual("m").toString()+result.getNamedIndividual("p").toString()+"\n";
	 			//Dispalynig.addRowTable(new Object[]{ result.getNamedIndividual("m"),
result.getNamedIndividual("p")});
	 			
		 }
	 		JOptionPane jop1 = new JOptionPane();
	 		   jop1.showMessageDialog(null, Message,  null,
JOptionPane.WARNING_MESSAGE);
				}	
	catch (OWLOntologyCreationException e) {
	      System.err.println("Error creating OWL ontology: " + e.getMessage());
	      System.exit(-1);
	    } catch (SWRLParseException e) {
	      System.err.println("Error parsing SQWRL query: " + e.getMessage());
	      System.exit(-1);
	    } catch (SQWRLException e) {
	      System.err.println("Error running SQWRL query: " + e.getMessage());
	      System.exit(-1);
	    } catch (RuntimeException e) {
	      System.err.println("Error starting application: " + e.getMessage());
	      System.exit(-1);
	    }

	}
	
	
	
	
}*

if you have any idea to help me please tell me it 
Thank you very much 





--
View this message in context: http://protege-project.136.n4.nabble.com/inference-engine-and-rules-tp4667237p4667242.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: inference engine and rules

Talya
Sir Lorenz,
we suppose that I'm a user who don't know about protege and even ontology;
ok from a Java application I add Martin (I just have a graphical interface I create the name the surname, and the score in English) then through a button (add) this student is added to the ontology then I have a button mention when I press it I would know the mention.
as I tell you the swrl rule is well executed, but with the old instances and does not take into account Martin. for that I was obliged to reopen my ontology in protege and to execute the SWRL rule another time in order to give me the correct answer
the user does not know these instructions. so for him all these steps should be effectuated automatically without his interaction.
Hope it is clear
so the question is
how to execute the SWRL  rule for the second time (Third time) via java code (without using protege)?
Reply | Threaded
Open this post in threaded view
|

Re: inference engine and rules

Lorenz B.
And adding the axioms for Martin first does not work? OWL API examples will show how to add axioms.

Sir Lorenz, 
we suppose that I'm a user who don't know about protege and even ontology;
ok from a Java application I add Martin (I just have a graphical interface I
create the name the surname, and the score in English) then through a button
(add) this student is added to the ontology then I have a button mention
when I press it I would know the mention. 
as I tell you the swrl rule is well executed, but with the old instances and
does not take into account Martin. for that I was obliged to reopen my
ontology in protege and to execute the SWRL rule another time in order to
give me the correct answer
the user does not know these instructions. so for him all these steps should
be effectuated automatically without his interaction. 
Hope it is clear 
so the question is 
how to execute the SWRL  rule for the second time (Third time) via java code
(without using protege)? 



--
View this message in context: http://protege-project.136.n4.nabble.com/inference-engine-and-rules-tp4667237p4667248.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: inference engine and rules

Talya
Good day
Really, what I know about Axioms is to express relations between classes such (sub-class of, instances, disjunction, equivalence, etc....)
But in my case I really don't understand what axioms should I adding and how it can resolve the problem if it is possible help me with example and references, links to understand well
Thank you very much
Reply | Threaded
Open this post in threaded view
|

Re: inference engine and rules

Lorenz B.
Sorry,  I cannot follow you.


1. you have an ontology, right?

2. a new user wants to be added?

3. this means to add axioms to the ontology, all statements in an OWL
ontology are OWL axioms

4. then you can apply the same SWRL rules as before


If any step was wrong, please clarify.


On 04.01.2017 13:35, Talya wrote:

> Good day
> Really, what I know about Axioms is to express relations between classes
> such (sub-class of, instances, disjunction, equivalence, etc....)
> But in my case I really don't understand what axioms should I adding and how
> it can resolve the problem if it is possible help me with example and
> references, links to understand well
> Thank you very much
>
>
>
> --
> View this message in context: http://protege-project.136.n4.nabble.com/inference-engine-and-rules-tp4667237p4667251.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: inference engine and rules

Talya
Hello,
Yes, all the three steps are ok.
the last step, how may I execute the SWRL rule another time (in order to take into account the new user) without go back to protege.
 I want to reactivate the inference engine once I add new users using Java code and not protege.
as I tell you we suppose that I don't know protege, ontology, SWRL, etc....
I have only a graphical interface first I add the new student and second I want to know his mention.
How may I update the execution of SWRL rule for the new student
Hope it is clear now
Thanks
Reply | Threaded
Open this post in threaded view
|

Re: inference engine and rules

Lorenz B.
In the step before you added data to the ontology. This will affect the inference process, thus:

IF the query engine has an ontology change listener (Martin O'Connor should know this), simply run the query again, i.e. call

queryEngine.runSQWRLQuery(...)



Hello, 
Yes, all the three steps are ok. 
the last step, how may I execute the SWRL rule another time (in order to
take into account the new user) without go back to protege. 
 I want to reactivate the inference engine once I add new users using Java
code and not protege. 
as I tell you we suppose that I don't know protege, ontology, SWRL, etc.... 
I have only a graphical interface first I add the new student and second I
want to know his mention. 
How may I update the execution of SWRL rule for the new student
Hope it is clear now 
Thanks 



--
View this message in context: http://protege-project.136.n4.nabble.com/inference-engine-and-rules-tp4667237p4667257.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: inference engine and rules

Talya
Thanks Sir Lorenz,
Hope that Sir Martin answer  me
Reply | Threaded
Open this post in threaded view
|

Re: inference engine and rules

Martin O'Connor-2
In reply to this post by Lorenz B.

The SWRLAPI’s reasoner does not respond to active ontology changes. Reasoning is performed when the SWRLRuleEngine.infer() method is called and the process terminates when all inferences have been made. If new knowledge is added to the associated ontology then the user is responsible for calling the infer() method again.

Martin

On Jan 5, 2017, at 2:34 AM, Lorenz B. <[hidden email]> wrote:

In the step before you added data to the ontology. This will affect the inference process, thus:

IF the query engine has an ontology change listener (Martin O'Connor should know this), simply run the query again, i.e. call

queryEngine.runSQWRLQuery(...)



Hello, 
Yes, all the three steps are ok. 
the last step, how may I execute the SWRL rule another time (in order to
take into account the new user) without go back to protege. 
 I want to reactivate the inference engine once I add new users using Java
code and not protege. 
as I tell you we suppose that I don't know protege, ontology, SWRL, etc.... 
I have only a graphical interface first I add the new student and second I
want to know his mention. 
How may I update the execution of SWRL rule for the new student
Hope it is clear now 
Thanks 



--
View this message in context: http://protege-project.136.n4.nabble.com/inference-engine-and-rules-tp4667237p4667257.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


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