You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Abduladem Eljamel <a_...@yahoo.co.uk.INVALID> on 2017/03/29 11:23:11 UTC

Jena Rules

Hello,I am trying to excute this rule in Jena:

[r1:  (?c http://somewhere#rel1 ?price) 
       (?c http://somewhere#rel2 ?value)       lessThan(?price, ?value) ->       (?y http://somewhere#AnyRelation 'Some Text')]
I have two questions:1- I would like ?y to be a specific instance of a specific class and created during the excution of the rule. How to create that instance in the rule? if it can be, is there a way that instance to be not blank node?
I found this in the Jena documentations: 

makeInstance(?x, ?p, ?v)makeInstance(?x, ?p, ?t, ?v)
but I do not know how to use it because ?v is the blank node so what is ?x?

2- How to add prefixes in rules?
ThanksAbdul



Re: Jena Rules

Posted by "Lorenz B." <bu...@informatik.uni-leipzig.de>.
If you have the URI of inst2, just write it, e.g.

-> (<http://somewhere#inst2> <http://somewhere#AnyRelation> 'Some Text'), (<http://somewhere#inst2> rdf:type <http://somewhere#class2>)



> Thank you Lorenz B�hmann for answering my email.
> But what do you mean by using the URI I have in mind?
>
> I want to create an instance to a class already in the ontology. For example, If I have these triples in my data:
> inst1 type class1
> inst1 hasPrice price
> inst1 hasValue value
> class2 type Class
> I would like the rule to be something like:
> if (price>value) then create inst2 of type class2 and add text value to inst2
> Thanks
> Abdul
>
>
>
>
>       From: Lorenz B. <bu...@informatik.uni-leipzig.de>
>  To: users@jena.apache.org 
>  Sent: Thursday, March 30, 2017 7:43 AM
>  Subject: Re: Jena Rules
>    
>
>> Hello,I am trying to excute this rule in Jena:
>>
>> [r1:  (?c http://somewhere#rel1 ?price) 
>>         (?c http://somewhere#rel2 ?value)      lessThan(?price, ?value) ->      (?y http://somewhere#AnyRelation 'Some Text')]
>> I have two questions:1- I would like ?y to be a specific instance of a specific class and created during the excution of the rule. How to create that instance in the rule? if it can be, is there a way that instance to be not blank node?
>> I found this in the Jena documentations: 
>>
>> makeInstance(?x, ?p, ?v)makeInstance(?x, ?p, ?t, ?v)
>> but I do not know how to use it because ?v is the blank node so what is ?x?
> That built-in only creates blank nodes used as a value for a known
> resource ?x and property ?p. If you want to create an instance, why
> don't you use the URI you have in mind?
>> 2- How to add prefixes in rules?
> You can add this to the file containing the rules:
>
> @prefix pre: <http://domain/url#>.
>
> >From the Jena documentation [1]: "Defines a prefix pre which can be used
> in the rules. The prefix is local to the rule file."
>
>
> [1] https://jena.apache.org/documentation/inference/#rules
>> ThanksAbdul
>>
>>
>>
-- 
Lorenz B�hmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center


Re: Jena Rules

Posted by Abduladem Eljamel <a_...@yahoo.co.uk.INVALID>.
Thank you Lorenz Bühmann for answering my email.
But what do you mean by using the URI I have in mind?

I want to create an instance to a class already in the ontology. For example, If I have these triples in my data:
inst1 type class1
inst1 hasPrice price
inst1 hasValue value
class2 type Class
I would like the rule to be something like:
if (price>value) then create inst2 of type class2 and add text value to inst2
Thanks
Abdul




      From: Lorenz B. <bu...@informatik.uni-leipzig.de>
 To: users@jena.apache.org 
 Sent: Thursday, March 30, 2017 7:43 AM
 Subject: Re: Jena Rules
   

> Hello,I am trying to excute this rule in Jena:
>
> [r1:  (?c http://somewhere#rel1 ?price) 
>        (?c http://somewhere#rel2 ?value)      lessThan(?price, ?value) ->      (?y http://somewhere#AnyRelation 'Some Text')]
> I have two questions:1- I would like ?y to be a specific instance of a specific class and created during the excution of the rule. How to create that instance in the rule? if it can be, is there a way that instance to be not blank node?
> I found this in the Jena documentations: 
>
> makeInstance(?x, ?p, ?v)makeInstance(?x, ?p, ?t, ?v)
> but I do not know how to use it because ?v is the blank node so what is ?x?
That built-in only creates blank nodes used as a value for a known
resource ?x and property ?p. If you want to create an instance, why
don't you use the URI you have in mind?
>
> 2- How to add prefixes in rules?
You can add this to the file containing the rules:

@prefix pre: <http://domain/url#>.

From the Jena documentation [1]: "Defines a prefix pre which can be used
in the rules. The prefix is local to the rule file."


[1] https://jena.apache.org/documentation/inference/#rules
> ThanksAbdul
>
>
>
-- 
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center



   

Re: Jena Rules

Posted by "Lorenz B." <bu...@informatik.uni-leipzig.de>.
> Hello,I am trying to excute this rule in Jena:
>
> [r1:  (?c http://somewhere#rel1 ?price) 
>        (?c http://somewhere#rel2 ?value)       lessThan(?price, ?value) ->       (?y http://somewhere#AnyRelation 'Some Text')]
> I have two questions:1- I would like ?y to be a specific instance of a specific class and created during the excution of the rule. How to create that instance in the rule? if it can be, is there a way that instance to be not blank node?
> I found this in the Jena documentations: 
>
> makeInstance(?x, ?p, ?v)makeInstance(?x, ?p, ?t, ?v)
> but I do not know how to use it because ?v is the blank node so what is ?x?
That built-in only creates blank nodes used as a value for a known
resource ?x and property ?p. If you want to create an instance, why
don't you use the URI you have in mind?
>
> 2- How to add prefixes in rules?
You can add this to the file containing the rules:

@prefix pre: <http://domain/url#>.

From the Jena documentation [1]: "Defines a prefix pre which can be used
in the rules. The prefix is local to the rule file."


[1] https://jena.apache.org/documentation/inference/#rules
> ThanksAbdul
>
>
>
-- 
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center