SWRL rules

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

SWRL rules

Azra
Hello,
I want to create an SWRLBuiltin that display a notification message, for example Person (? p) ^hasage (? p,? v) ^greaterThan (? v, 60) ->personal: builtin ("Vieil Homme",? v)
This message is shown as a notification message like the message returned with JOptionPane in fact, I try to do this by myself, but I'm not sure if it works or no here my proposition
Thanks in advance for your help
"public boolean notify(List<SWRLBuiltInArgument> arguments)
                   throws SWRLBuiltInException
                 {
                  final int argument1Number = 0, argument2Number = 1, numberOfArguments = 2;
                 
                  checkNumberOfArgumentsEqualTo(numberOfArguments, arguments.size());
                 // convert this arguments in string
                  String argument1 = getArgumentAsAString(argument1Number, arguments); // this argument contains first argument: Vieil Homme
                  String argument2 = getArgumentAsAString(argument2Number, arguments);// this argument contains the value of his age "?v"
                   JOptionPane jop1 = new JOptionPane();
                    jop1.showMessageDialog(null, argument1+argument2);
                    return (true);"
}
Reply | Threaded
Open this post in threaded view
|

Re: SWRL rules

Fatma ELLOUZE
Hello Azra,
As you will show a message, I advise you to just use the sqwrl:select. So you can not use the builtins in this case and your rule will be written like this:
Person (? p) ^hasage (? p,? v) ^greaterThan (? v, 60) -> sqwrl:select ("Vieil Homme")
Hope that will help you..
Best regards :)
Fatma.
Reply | Threaded
Open this post in threaded view
|

Re: SWRL rules

Azra
Hello Fatma; 
Thank you for your reply :) 
In fact I want to display this message and the age of this person in a notification message. 
Good day 




2016-08-28 22:52 GMT+01:00 Fatma ELLOUZE [via Protege Project] <[hidden email]>:
Hello Azra,
As you will show a message, I advise you to just use the sqwrl:select. So you can not use the builtins in this case and your rule will be written like this:
Person (? p) ^hasage (? p,? v) ^greaterThan (? v, 60) -> sqwrl:select ("Vieil Homme")
Hope that will help you..
Best regards :)
Fatma.


If you reply to this email, your message will be added to the discussion below:
http://protege-project.136.n4.nabble.com/SWRL-rules-tp4666272p4666273.html
To start a new topic under Protege Developer, email [hidden email]
To unsubscribe from SWRL rules, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: SWRL rules

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

Yes - querying the result of inference is the preferred approach here. You can then display the results of the query,

Performing a blocking action in a built-in would bring the entire inference process to a halt.

In general, rules are executed and any inference made are examined afterwards. There are cases where rules can perform some sort of external action - but such an action should not block.

Martin

> On Aug 28, 2016, at 2:52 PM, Fatma ELLOUZE <[hidden email]> wrote:
>
> Hello Azra,
> As you will show a message, I advise you to just use the sqwrl:select. So
> you can not use the builtins in this case and your rule will be written like
> this:
> Person (? p) ^hasage (? p,? v) ^greaterThan (? v, 60) -> sqwrl:select
> ("Vieil Homme")
> Hope that will help you..
> Best regards :)
> Fatma.
>
>
>
> --
> View this message in context: http://protege-project.136.n4.nabble.com/SWRL-rules-tp4666272p4666273.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