How to infer a single SWRL rule?

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

How to infer a single SWRL rule?

Fatma ELLOUZE
Hello everybody,
I have many SWRL rules in my ontology and I want to execute some of them. I am using Protege 5.0.0 and OWL API.
I used  ruleEngine.infer(); but this instruction execute all of them.
Please how can I specify the name of a given rule to be executed?
Thank you for your reply.
Best regards
Fatma.
Reply | Threaded
Open this post in threaded view
|

Re: How to infer a single SWRL rule?

Lorenz Buehmann
What is the relationship to Protege?

You are running some Java code, so this is more a SWRL API related
question. And without seeing the code, nobody can help you.


> I have many SWRL rules in my ontology and I want to execute some of them. I
> am using Protege 5.0.0 and OWL API.
> I used  ruleEngine.infer(); but this instruction execute all of them.
> Please how can I specify the name of a given rule to be executed?
> Thank you for your reply.
> Best regards
> Fatma.
>
>
>
> --
> View this message in context: http://protege-project.136.n4.nabble.com/How-to-infer-a-single-SWRL-rule-tp4666452.html
> Sent from the Protege User mailing list archive at Nabble.com.
> _______________________________________________
> protege-user mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-user
>
--
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center

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

Re: How to infer a single SWRL rule?

Fatma ELLOUZE
Thanks for you reply.
My issue have no relationship even with SWRL rules. I explain more: I have a set of SQWRL queries that I want to run them. So I write this java code below:

SQWRLQueryEngine queryEngine = SWRLAPIFactory.createSQWRLQueryEngine(ontology);
Set <String> resultNames = queryEngine.getSQWRLQueryNames();
         ArrayList<String> resultNamesAss= new ArrayList() ;
          for (String s:resultNames)
            {
                if (s.contains("SarProcIPSAR")){
                    resultNamesAss.add(s);
                 }
            }
            for(int i=0; i<resultNamesAss.size(); i++){
               val= queryEngine.runSQWRLQuery("SarProcIPSAR" +j +"").toString();}
It runs succesfully however these queries are running only after running all my SWRL rules already exist in my ontology. However, I want to execute only a subset of my SWRL rules. My question is "Can I do that?"
Thank you for your help
Best regards
Fatma.
Reply | Threaded
Open this post in threaded view
|

Re: How to infer a single SWRL rule?

Lorenz Buehmann
And again, this is a Protege mailing list, not an SWRL API list...

According to your code, obviously the way would be to generate an
ontology object that contains only the single rule that you want to be
executed + all other axioms.

> My issue have no relationship even with SWRL rules. I explain more: I have a
> set of SQWRL queries that I want to run them. So I write this java code
> below:
>
> SQWRLQueryEngine queryEngine =
> SWRLAPIFactory.createSQWRLQueryEngine(ontology);
> Set <String> resultNames = queryEngine.getSQWRLQueryNames();
>          ArrayList<String> resultNamesAss= new ArrayList() ;
>           for (String s:resultNames)
>             {
>                 if (s.contains("SarProcIPSAR")){
>                     resultNamesAss.add(s);
>                  }
>             }
>             for(int i=0; i<resultNamesAss.size(); i++){
>                val= queryEngine.runSQWRLQuery("SarProcIPSAR" +j
> +"").toString();}
> It runs succesfully however these queries are running only after running all
> my SWRL rules already exist in my ontology. However, I want to execute only
> a subset of my SWRL rules. My question is "Can I do that?"
> Thank you for your help
> Best regards
> Fatma.
>
>
>
> --
> View this message in context: http://protege-project.136.n4.nabble.com/How-to-infer-a-single-SWRL-rule-tp4666452p4666455.html
> Sent from the Protege User mailing list archive at Nabble.com.
> _______________________________________________
> protege-user mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-user
>
--
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center

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

Re: How to infer a single SWRL rule?

Fatma ELLOUZE
Thank you very much and I am sorry if I insist.
with my best regards
Fatma
Reply | Threaded
Open this post in threaded view
|

Re: How to infer a single SWRL rule?

Martin O'Connor-2

The SWRLAPI does not currently support selective rule enabling/disabling.

This feature will likely be available in a month or so.

Martin

> On Sep 19, 2016, at 5:41 AM, Fatma ELLOUZE <[hidden email]> wrote:
>
> Thank you very much and I am sorry if I insist.
> with my best regards
> Fatma
>
>
>
> --
> View this message in context: http://protege-project.136.n4.nabble.com/How-to-infer-a-single-SWRL-rule-tp4666452p4666458.html
> Sent from the Protege User mailing list archive at Nabble.com.
> _______________________________________________
> protege-user mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-user


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

Re: How to infer a single SWRL rule?

Fatma ELLOUZE
Thank you Mr. Martin for your reply.
I just searching for that and I find that when using jena, you can do that. You find, below, the code:

SWRLRuleEngine swrlRuleEngine = SWRLAPIFactory.createSWRLRuleEngine(ontology);
// Run the SWRL rules in the ontology
swrlRuleEngine.infer();
   
String rulename ="S1";
   
factory.disableAll();

SQWRLResult result = queryEngine.runSQWRLQuery("S1");

Please, just question, can I use in the same project "Jena" and "OWL API"?
Thanks for replying
Best regards
Fatma.
Reply | Threaded
Open this post in threaded view
|

Re: How to infer a single SWRL rule?

Martin O'Connor-2

Jena and the OWLAPI will not work together.

I don’t understand the factory.disableAll() call. What is the type of the factory instance?

Martin

> On Sep 19, 2016, at 9:14 AM, Fatma ELLOUZE <[hidden email]> wrote:
>
> Thank you Mr. Martin for your reply.
> I just searching for that and I find that when using jena, you can do that.
> You find, below, the code:
>
> SWRLRuleEngine swrlRuleEngine =
> SWRLAPIFactory.createSWRLRuleEngine(ontology);
> // Run the SWRL rules in the ontology
> swrlRuleEngine.infer();
>    
> String rulename ="S1";
>    
> factory.disableAll();
>
> SQWRLResult result = queryEngine.runSQWRLQuery("S1");
>
> Please, just question, can I use in the same project "Jena" and "OWL API"?
> Thanks for replying
> Best regards
> Fatma.
>
>
>
> --
> View this message in context: http://protege-project.136.n4.nabble.com/How-to-infer-a-single-SWRL-rule-tp4666452p4666463.html
> Sent from the Protege User mailing list archive at Nabble.com.
> _______________________________________________
> protege-user mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protege-user

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

Re: How to infer a single SWRL rule?

Fatma ELLOUZE
the principle is to disable all SWRL rules and then enable one of them to run it.
the type of the factory is: SWRLFactory
Here is the code:

import edu.stanford.smi.protegex.owl.swrl.model.SWRLFactory;
...
private static SWRLFactory factory;
.....
...
OWL_FILE = "ContextBPMOntology.owl";
File file = new File(OWL_FILE);
owlModel = ProtegeOWL.createJenaOWLModelFromURI(file.toURI().toString());
factory = new SWRLFactory(owlModel);
String rulename ="http://www.owl-ontologies.com/Ass1";
factory.disableAll();
factory.getImp(rulename).enable();
SQWRLQueryEngine QueryEngine= SQWRLQueryEngineFactory.create(owlModel);
QueryEngine.runSQWRLQuery(rulename);
SQWRLResult result = QueryEngine.getSQWRLResult(rulename);
....
..
PS: However I don’t understand why Jena and the OWLAPI will not work together...
With my best regards
Fatma
Reply | Threaded
Open this post in threaded view
|

Re: How to infer a single SWRL rule?

Lorenz Buehmann
Indeed you can use both APIs in the same project and also in the same Java class, but both APIs do not share any common interface, thus, an OWL API ontology has no relationship to a Jena model and you would always have to convert all objects between both APIs. Which is quite obvious as both API are totally different, with different goals and implemented by different groups of people.

the principle is to disable all SWRL rules and then enable one of them to run
it.
the type of the factory is: SWRLFactory 
Here is the code:

import edu.stanford.smi.protegex.owl.swrl.model.SWRLFactory;
...
private static SWRLFactory factory;
.....
...
OWL_FILE = "ContextBPMOntology.owl";
File file = new File(OWL_FILE);
owlModel = ProtegeOWL.createJenaOWLModelFromURI(file.toURI().toString());
factory = new SWRLFactory(owlModel);
String rulename ="http://www.owl-ontologies.com/Ass1";
factory.disableAll();
factory.getImp(rulename).enable();
SQWRLQueryEngine QueryEngine= SQWRLQueryEngineFactory.create(owlModel);
QueryEngine.runSQWRLQuery(rulename);
SQWRLResult result = QueryEngine.getSQWRLResult(rulename);
....
..
PS: However I don’t understand why Jena and the OWLAPI will not work
together...
With my best regards
Fatma




--
View this message in context: http://protege-project.136.n4.nabble.com/How-to-infer-a-single-SWRL-rule-tp4666452p4666468.html
Sent from the Protege User mailing list archive at Nabble.com.
_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user


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

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

Re: How to infer a single SWRL rule?

Fatma ELLOUZE
It's OK. Thanks Mr. Lorenz for this clarification.
Best regards
Fatma