You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Christophe FAGOT <fa...@intactile.com> on 2014/01/16 21:34:01 UTC
noValue builtIn effects
Hi,
I'm trying to implement in Jena rules some behavior such as "If there is no value for property P, then property Q = v1, else property Q = v2". Since I need Jena to react "live" to triples adding and removal, I use it in FORWARD_RETE.
I'm using the buildIn "noValue(?x, ?p)" as following :
@prefix test: <http://myURL/mySpace#>
@prefix owl: <http://www.w3.org/2002/07/owl>
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
@prefix xs: <http://www.w3.org/2001/XMLSchema#>
[rule1: (?icon rdf:type test:Icon),
noValue(?icon, test:imagePath)
->
(?icon test:scale "1"^^xsd:double)]
[rule2: (?icon rdf:type test:Icon),
(?icon test:imagePath ?value)
->
(?icon test:scale "2"^^xsd:double)]
First of all, am I right if I say that with such rules, I will have the 2 triples
(http://myURL/mySpace#myIcon http://myURL/mySpace#scale '1'^^http://www.w3.org/2001/XMLSchema#double) and
(http://myURL/mySpace#myIcon http://myURL/mySpace#scale '2'^^http://www.w3.org/2001/XMLSchema#double)
… if I add my triples in that order :
1) (http://myURL/mySpace#myIcon rdf:type http://myURL/mySpace#Icon)
2) (http://myURL/mySpace#myIcon http://myURL/mySpace#imagePath 'path'^^http://www.w3.org/2001/XMLSchema#string)
And the reason is that when I add my second triple, the buildIn "noValue" don't "react" like if one would remove a value matching with it, and hence the rule don't remove its deduced triple.
Am I also right if I say that the only way to do it with a FORWARD_RETE is to use a "remove" builtIn in my rule2 ?
Thank you,
Chris.
Christophe FAGOT, PhD - Product owner, informatique
:: intactile DESIGN :: création industrielle en Interface Homme Machine [ IHM ] :: 20 rue du carré du roi :: 34000 MONTPELLIER :: France
:: +33 (0)4 67 52 88 61 :: +33 (0)9 50 12 05 66 :: fagot.c@intactile.com :: http://www.intactile.com
Hugh MacLeod : "It's not what the software does, it's what the user does"
Les informations contenues dans cet email et ses documents attachés sont confidentielles. Elles sont exclusivement adressées aux destinataires explicitement désignés ci-dessus et ne peuvent être divulguées sans consentement de son auteur. Si vous n'êtes pas le destinataire de cet email vous ne devez pas employer, révéler, distribuer, copier, imprimer ou transmettre le contenu de cet email et devez le détruire immédiatement.
Re: noValue builtIn effects
Posted by Christophe FAGOT <fa...@intactile.com>.
Thanks for that confirmation Dave.
Chris.
Le 17 janv. 2014 à 08:33, Dave Reynolds <da...@gmail.com> a écrit :
> On 16/01/14 20:34, Christophe FAGOT wrote:
>> Hi,
>>
>> I'm trying to implement in Jena rules some behavior such as "If there is no value for property P, then property Q = v1, else property Q = v2". Since I need Jena to react "live" to triples adding and removal, I use it in FORWARD_RETE.
>
> Ugh. This should be possible but Jena rules were originally designed for monotonic inference to match RDF semantics. The novalue/remove builtins are ugly late additions and can be very confusing and not as easy to use as a proper production rule system.
>
> [Monotonic reasoning means that whatever you can conclude from some set of facts remains true when more facts are added.]
>
>> I'm using the buildIn "noValue(?x, ?p)" as following :
>>
>> @prefix test: <http://myURL/mySpace#>
>> @prefix owl: <http://www.w3.org/2002/07/owl>
>> @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
>> @prefix xs: <http://www.w3.org/2001/XMLSchema#>
>
> [Aside: that should be xsd: for what you use below]
>
>> [rule1: (?icon rdf:type test:Icon),
>> noValue(?icon, test:imagePath)
>> ->
>> (?icon test:scale "1"^^xsd:double)]
>>
>> [rule2: (?icon rdf:type test:Icon),
>> (?icon test:imagePath ?value)
>> ->
>> (?icon test:scale "2"^^xsd:double)]
>>
>> First of all, am I right if I say that with such rules, I will have the 2 triples
>> (http://myURL/mySpace#myIcon http://myURL/mySpace#scale '1'^^http://www.w3.org/2001/XMLSchema#double) and
>> (http://myURL/mySpace#myIcon http://myURL/mySpace#scale '2'^^http://www.w3.org/2001/XMLSchema#double)
>> … if I add my triples in that order :
>> 1) (http://myURL/mySpace#myIcon rdf:type http://myURL/mySpace#Icon)
>> 2) (http://myURL/mySpace#myIcon http://myURL/mySpace#imagePath 'path'^^http://www.w3.org/2001/XMLSchema#string)
>>
>> And the reason is that when I add my second triple, the buildIn "noValue" don't "react" like if one would remove a value matching with it, and hence the rule don't remove its deduced triple.
>
> Yes.
>
>> Am I also right if I say that the only way to do it with a FORWARD_RETE is to use a "remove" builtIn in my rule2 ?
>
> You'll need to split rule2 into two parts. Something like *UNTESTED*
>
> [rule2a: (?icon rdf:type test:Icon),
> (?icon test:imagePath ?value)
> ->
> (?icon test:scale "2"^^xsd:double)]
>
> [rule2b: (?icon rdf:type test:Icon),
> (?icon test:imagePath ?value)
> (?icon test:scale "1"^^xsd:double)
> ->
> remove(2)]
>
> And you'll need something similar for rule1 if you want to allow for removing triples as well.
>
> Dave
>
Christophe FAGOT, PhD - Product owner, informatique
:: intactile DESIGN :: création industrielle en Interface Homme Machine [ IHM ] :: 20 rue du carré du roi :: 34000 MONTPELLIER :: France
:: +33 (0)4 67 52 88 61 :: +33 (0)9 50 12 05 66 :: fagot.c@intactile.com :: http://www.intactile.com
Hugh MacLeod : "It's not what the software does, it's what the user does"
Les informations contenues dans cet email et ses documents attachés sont confidentielles. Elles sont exclusivement adressées aux destinataires explicitement désignés ci-dessus et ne peuvent être divulguées sans consentement de son auteur. Si vous n'êtes pas le destinataire de cet email vous ne devez pas employer, révéler, distribuer, copier, imprimer ou transmettre le contenu de cet email et devez le détruire immédiatement.
Re: noValue builtIn effects
Posted by Dave Reynolds <da...@gmail.com>.
On 16/01/14 20:34, Christophe FAGOT wrote:
> Hi,
>
> I'm trying to implement in Jena rules some behavior such as "If there is no value for property P, then property Q = v1, else property Q = v2". Since I need Jena to react "live" to triples adding and removal, I use it in FORWARD_RETE.
Ugh. This should be possible but Jena rules were originally designed for
monotonic inference to match RDF semantics. The novalue/remove builtins
are ugly late additions and can be very confusing and not as easy to use
as a proper production rule system.
[Monotonic reasoning means that whatever you can conclude from some set
of facts remains true when more facts are added.]
> I'm using the buildIn "noValue(?x, ?p)" as following :
>
> @prefix test: <http://myURL/mySpace#>
> @prefix owl: <http://www.w3.org/2002/07/owl>
> @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
> @prefix xs: <http://www.w3.org/2001/XMLSchema#>
[Aside: that should be xsd: for what you use below]
> [rule1: (?icon rdf:type test:Icon),
> noValue(?icon, test:imagePath)
> ->
> (?icon test:scale "1"^^xsd:double)]
>
> [rule2: (?icon rdf:type test:Icon),
> (?icon test:imagePath ?value)
> ->
> (?icon test:scale "2"^^xsd:double)]
>
> First of all, am I right if I say that with such rules, I will have the 2 triples
> (http://myURL/mySpace#myIcon http://myURL/mySpace#scale '1'^^http://www.w3.org/2001/XMLSchema#double) and
> (http://myURL/mySpace#myIcon http://myURL/mySpace#scale '2'^^http://www.w3.org/2001/XMLSchema#double)
> … if I add my triples in that order :
> 1) (http://myURL/mySpace#myIcon rdf:type http://myURL/mySpace#Icon)
> 2) (http://myURL/mySpace#myIcon http://myURL/mySpace#imagePath 'path'^^http://www.w3.org/2001/XMLSchema#string)
>
> And the reason is that when I add my second triple, the buildIn "noValue" don't "react" like if one would remove a value matching with it, and hence the rule don't remove its deduced triple.
Yes.
> Am I also right if I say that the only way to do it with a FORWARD_RETE is to use a "remove" builtIn in my rule2 ?
You'll need to split rule2 into two parts. Something like *UNTESTED*
[rule2a: (?icon rdf:type test:Icon),
(?icon test:imagePath ?value)
->
(?icon test:scale "2"^^xsd:double)]
[rule2b: (?icon rdf:type test:Icon),
(?icon test:imagePath ?value)
(?icon test:scale "1"^^xsd:double)
->
remove(2)]
And you'll need something similar for rule1 if you want to allow for
removing triples as well.
Dave