You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Soheila Dehghanzadeh <so...@yahoo.com> on 2014/03/10 10:08:20 UTC
Reasoning on a combined dataset of query solution and dataset
Hi All,
I ran a query on a dataset and i have the result binding of my query solutions.
sol1: user=u1, location=loc1, LocationType=type1sol2: user=u1, location=loc2, LocationType=type2
now i want to extend my existing query result set with an inference rule. This inference rule requires combining the existing dataset with above result set to extend the result set by adding new solutions.
@prefix pre: <http://jena.hpl.hp.com/prefix#>.
[rule1:
(?sol pre:user ?a) (?sol pre:location ?b) (?sol pre:lcationType
?c)
(?b location:ispartof ?d) (?d rdf:type ?type)
-> (sol2 pre:user
?a) (sol2 pre:location ?d) (sol2 pre:locationType ?type) ]
As we can see in the rule above all rules will endup adding properties to sol2 while in fact i want sol2 get a dynamic name for each new inference and add a new solution not adding properties to the same solution. any comment is greatly appreciated.
thanks.
Re: Reasoning on a combined dataset of query solution and dataset
Posted by Arthur Vaïsse-Lesteven <ar...@yahoo.fr>.
I don't know how to do it via Jena rule, but Such a request probably do what you want :
INSERT {
graph1 { statements }
graph2 { statements }
}
WHERE {
graph1 { tripe pattern }
graph2 { triple pattern }
}
To match your example
>> [resultExpansion:
>> (?sol me:user ?u) ======> from graph2
>> (?sol me:location ?loc) ======> from graph2
>> (?loc dbo:isPartOf ?loc2) ======> from graph1
>> ->
>> (?u dbo:location ?loc2) ======> add to graph1
>> (?sol me:location ?loc2) ======> add to graph2
>> ]
It gives such a thing:
INSERT{
GRAPH ?graph1 {
?u dbo:location ?loc2
}
GRAPH ?graph2 {
?sol me:location ?loc2
}
}
WHERE{
GRAPH ?graph1{
?loc dbo:isPartOf ?loc2
}
GRAPH ?graph2 { ?sol me:user ?u,
?sol me:location ?loc
}
}
"SPIN: SPARQL INferencing Notation" framework allows the use of SPARQL queries as a way of reasonning (http://spinrdf.org/) if you can't express quad patterns using jena rules.
(I'm not linked in any way to the SPIN publishers)
________________________________
De : Soheila Dehghanzadeh <so...@yahoo.com>
À : "users@jena.apache.org" <us...@jena.apache.org>
Envoyé le : Mardi 11 mars 2014 8h54
Objet : Re: Reasoning on a combined dataset of query solution and dataset
Thanks Dave,
actually i have a graph that i want to keep it *intact* while extending my solution with it.
for example consider this solution :
sol1: user=u1, location=Boston, LocationType=city
i want to extend it to
sol2: user=u1, location=USA, LocationType=country
sol3: user=u1, location=America, LocationType=continent
This requires access to two graphs; graph1 contains these triples:
Boston dbo:isPartOf USA
USA rdf:type Country
USA dbo:isPartOf America
America rdf:type continent
and graph2 which contains:
Sol1 user u1
Sol1 location Boston
Sol1 LocationType city
i want to keep graph1 *inact* so that i can use it for future solution extensions. This requires writing this reasoning rule on abovegraphs
:
[resultExpansion:
(?sol me:user ?u) ======> from graph2
(?sol me:location ?loc) ======> from graph2
(?loc dbo:isPartOf ?loc2) ======> from graph1
->
(?u dbo:location ?loc2) ======> add to graph1
(?sol me:location ?loc2) ======> add to graph2
]
any idea how to write this role which works of 2 different graphs?
Thanks.
On Tuesday, March 11, 2014 7:43 AM, Soheila Dehghanzadeh <so...@yahoo.com> wrote:
Thanks Dave,
actually i have a graph that i want to keep it *intact* while extending my solution with it.
for example consider this solution:
sol1: user=u1, location=Boston, LocationType=city
i want to extend it to
sol2: user=u1, location=USA, LocationType=country
sol3: user=u1, location=America, LocationType=continent
This requires access to two graphs; graph1 contains these triples:
Boston dbo:isPartOf USA
USA rdf:type Country
USA dbo:isPartOf America
America rdf:type continent
and graph2 which contains:
Sol1 user u1
Sol1 location Boston
Sol1 LocationType city
i want to keep graph1 *inact* so that i can use it for future solution extensions. This requires writing this reasoning rule on above graphs
:
[resultExpansion:
(?sol me:user?u) ======> from graph2
(?sol me:location ?loc) ======> from graph2
(?loc dbo:isPartOf?loc2) ======> from graph1
->
(?u dbo:location?loc2) ======> add to graph1
(?sol me:location?loc2) ======> add to graph2
]
any idea how to write this role which works of 2 different graphs?
Thanks.
On Monday, March 10, 2014 5:18 PM, Dave Reynolds <da...@gmail.com> wrote:
On 10/03/14 09:08, Soheila Dehghanzadeh wrote:
> Hi All,
>
> I ran a query on a dataset and i have the result binding of my query solutions.
> sol1: user=u1, location=loc1, LocationType=type1sol2: user=u1, location=loc2, LocationType=type2
> now i want to extend my existing query result set with an inference rule. This inference rule requires combining the existing dataset with above result set to extend the result set by adding new solutions.
>
> @prefix pre: <http://jena.hpl.hp.com/prefix#>.
>
> [rule1:
>
> (?sol pre:user?a) (?sol pre:location?b) (?sol pre:lcationType
> ?c)
>
> (?b location:ispartof?d) (?d rdf:type?type)
>
> -> (sol2 pre:user
> ?a) (sol2 pre:location?d) (sol2 pre:locationType?type)]
> As we can see in the rule above all rules
will endup adding properties to sol2 while in fact i want sol2 get a dynamic name for each new inference and add a new solution not adding properties to the same solution. any comment is greatly appreciated.
Not sure I follow the requirement exactly but if you want a rule to
create a new resource you have two choices - create a blank node or
create a URI node with some synthesized URI. See makeTemp & makeSkolem
for the first case, see uriConcat for the second.
Be careful that don't end up with a rule which will keep matching on its
own results and creating an unbounded number of new resources.
Dave
Re: Reasoning on a combined dataset of query solution and dataset
Posted by Dave Reynolds <da...@gmail.com>.
The rules engines do not know about graphs, so you can't assert into
specific graphs directly from a pure rule set.
However, the rules engines don't modify the source model. In the case of
forward rules the additional results are stored in the associated
deductions model.
So you could have external code which takes the result of rule inference
and copies the deduction graph into some other graph of your choice.
Dave
On 11/03/14 07:54, Soheila Dehghanzadeh wrote:
> Thanks Dave,
> actually i have a graph that i want to keep it *intact* while extending my solution with it.
> for example consider this solution :
> sol1: user=u1, location=Boston, LocationType=city
>
> i want to extend it to
>
> sol2: user=u1, location=USA, LocationType=country
>
> sol3: user=u1, location=America, LocationType=continent
>
>
> This requires access to two graphs; graph1 contains these triples:
>
> Boston dbo:isPartOf USA
> USA rdf:type Country
> USA dbo:isPartOf America
> America rdf:type continent
>
> and graph2 which contains:
>
> Sol1 user u1
> Sol1 location Boston
> Sol1 LocationType city
>
> i want to keep graph1 *inact* so that i can use it for future solution extensions. This requires writing this reasoning rule on abovegraphs
>
> :
> [resultExpansion:
> (?sol me:user ?u) ======> from graph2
> (?sol me:location ?loc) ======> from graph2
> (?loc dbo:isPartOf ?loc2) ======> from graph1
> ->
> (?u dbo:location ?loc2) ======> add to graph1
> (?sol me:location ?loc2) ======> add to graph2
> ]
> any idea how to write this role which works of 2 different graphs?
>
> Thanks.
>
>
>
> On Tuesday, March 11, 2014 7:43 AM, Soheila Dehghanzadeh <so...@yahoo.com> wrote:
>
> Thanks Dave,
> actually i have a graph that i want to keep it *intact* while extending my solution with it.
> for example consider this solution:
> sol1: user=u1, location=Boston, LocationType=city
>
> i want to extend it to
>
> sol2: user=u1, location=USA, LocationType=country
>
> sol3: user=u1, location=America, LocationType=continent
>
>
> This requires access to two graphs; graph1 contains these triples:
>
> Boston dbo:isPartOf USA
> USA rdf:type Country
> USA dbo:isPartOf America
> America rdf:type continent
>
> and graph2 which contains:
>
> Sol1 user u1
> Sol1 location Boston
> Sol1 LocationType city
>
> i want to keep graph1 *inact* so that i can use it for future solution extensions. This requires writing this reasoning rule on above graphs
>
> :
> [resultExpansion:
> (?sol me:user?u) ======> from graph2
> (?sol me:location ?loc) ======> from graph2
> (?loc dbo:isPartOf?loc2) ======> from graph1
> ->
> (?u dbo:location?loc2) ======> add to graph1
> (?sol me:location?loc2) ======> add to graph2
> ]
> any idea how to write this role which works of 2 different graphs?
>
> Thanks.
>
>
>
> On Monday, March 10, 2014 5:18 PM, Dave Reynolds <da...@gmail.com> wrote:
>
> On 10/03/14 09:08, Soheila Dehghanzadeh wrote:
>
>> Hi All,
>>
>> I ran a query on a dataset and i have the result binding of my query solutions.
>> sol1: user=u1, location=loc1, LocationType=type1sol2: user=u1, location=loc2, LocationType=type2
>> now i want to extend my existing query result set with an inference rule. This inference rule requires combining the existing dataset with above result set to extend the result set by adding new solutions.
>>
>> @prefix pre: <http://jena.hpl.hp.com/prefix#>.
>>
>> [rule1:
>>
>> (?sol pre:user?a) (?sol pre:location?b) (?sol pre:lcationType
>> ?c)
>>
>> (?b location:ispartof?d) (?d rdf:type?type)
>>
>> -> (sol2 pre:user
>> ?a) (sol2 pre:location?d) (sol2 pre:locationType?type)]
>> As we can see in the rule above all rules
> will endup adding properties to sol2 while in fact i want sol2 get a dynamic name for each new inference and add a new solution not adding properties to the same solution. any comment is greatly appreciated.
>
> Not sure I follow the requirement exactly but if you want a rule to
> create a new resource you have two choices - create a blank node or
> create a URI node with some synthesized URI. See makeTemp & makeSkolem
> for the first case, see uriConcat for the second.
>
> Be careful that don't end up with a rule which will keep matching on its
> own results and creating an unbounded number of new resources.
>
> Dave
>
Re: Reasoning on a combined dataset of query solution and dataset
Posted by Soheila Dehghanzadeh <so...@yahoo.com>.
Thanks Dave,
actually i have a graph that i want to keep it *intact* while extending my solution with it.
for example consider this solution :
sol1: user=u1, location=Boston, LocationType=city
i want to extend it to
sol2: user=u1, location=USA, LocationType=country
sol3: user=u1, location=America, LocationType=continent
This requires access to two graphs; graph1 contains these triples:
Boston dbo:isPartOf USA
USA rdf:type Country
USA dbo:isPartOf America
America rdf:type continent
and graph2 which contains:
Sol1 user u1
Sol1 location Boston
Sol1 LocationType city
i want to keep graph1 *inact* so that i can use it for future solution extensions. This requires writing this reasoning rule on abovegraphs
:
[resultExpansion:
(?sol me:user ?u) ======> from graph2
(?sol me:location ?loc) ======> from graph2
(?loc dbo:isPartOf ?loc2) ======> from graph1
->
(?u dbo:location ?loc2) ======> add to graph1
(?sol me:location ?loc2) ======> add to graph2
]
any idea how to write this role which works of 2 different graphs?
Thanks.
On Tuesday, March 11, 2014 7:43 AM, Soheila Dehghanzadeh <so...@yahoo.com> wrote:
Thanks Dave,
actually i have a graph that i want to keep it *intact* while extending my solution with it.
for example consider this solution:
sol1: user=u1, location=Boston, LocationType=city
i want to extend it to
sol2: user=u1, location=USA, LocationType=country
sol3: user=u1, location=America, LocationType=continent
This requires access to two graphs; graph1 contains these triples:
Boston dbo:isPartOf USA
USA rdf:type Country
USA dbo:isPartOf America
America rdf:type continent
and graph2 which contains:
Sol1 user u1
Sol1 location Boston
Sol1 LocationType city
i want to keep graph1 *inact* so that i can use it for future solution extensions. This requires writing this reasoning rule on above graphs
:
[resultExpansion:
(?sol me:user?u) ======> from graph2
(?sol me:location ?loc) ======> from graph2
(?loc dbo:isPartOf?loc2) ======> from graph1
->
(?u dbo:location?loc2) ======> add to graph1
(?sol me:location?loc2) ======> add to graph2
]
any idea how to write this role which works of 2 different graphs?
Thanks.
On Monday, March 10, 2014 5:18 PM, Dave Reynolds <da...@gmail.com> wrote:
On 10/03/14 09:08, Soheila Dehghanzadeh wrote:
> Hi All,
>
> I ran a query on a dataset and i have the result binding of my query solutions.
> sol1: user=u1, location=loc1, LocationType=type1sol2: user=u1, location=loc2, LocationType=type2
> now i want to extend my existing query result set with an inference rule. This inference rule requires combining the existing dataset with above result set to extend the result set by adding new solutions.
>
> @prefix pre: <http://jena.hpl.hp.com/prefix#>.
>
> [rule1:
>
> (?sol pre:user?a) (?sol pre:location?b) (?sol pre:lcationType
> ?c)
>
> (?b location:ispartof?d) (?d rdf:type?type)
>
> -> (sol2 pre:user
> ?a) (sol2 pre:location?d) (sol2 pre:locationType?type)]
> As we can see in the rule above all rules
will endup adding properties to sol2 while in fact i want sol2 get a dynamic name for each new inference and add a new solution not adding properties to the same solution. any comment is greatly appreciated.
Not sure I follow the requirement exactly but if you want a rule to
create a new resource you have two choices - create a blank node or
create a URI node with some synthesized URI. See makeTemp & makeSkolem
for the first case, see uriConcat for the second.
Be careful that don't end up with a rule which will keep matching on its
own results and creating an unbounded number of new resources.
Dave
Re: Reasoning on a combined dataset of query solution and dataset
Posted by Dave Reynolds <da...@gmail.com>.
On 10/03/14 09:08, Soheila Dehghanzadeh wrote:
> Hi All,
>
> I ran a query on a dataset and i have the result binding of my query solutions.
> sol1: user=u1, location=loc1, LocationType=type1sol2: user=u1, location=loc2, LocationType=type2
> now i want to extend my existing query result set with an inference rule. This inference rule requires combining the existing dataset with above result set to extend the result set by adding new solutions.
>
> @prefix pre: <http://jena.hpl.hp.com/prefix#>.
>
> [rule1:
>
> (?sol pre:user ?a) (?sol pre:location ?b) (?sol pre:lcationType
> ?c)
>
> (?b location:ispartof ?d) (?d rdf:type ?type)
>
> -> (sol2 pre:user
> ?a) (sol2 pre:location ?d) (sol2 pre:locationType ?type) ]
> As we can see in the rule above all rules will endup adding properties to sol2 while in fact i want sol2 get a dynamic name for each new inference and add a new solution not adding properties to the same solution. any comment is greatly appreciated.
Not sure I follow the requirement exactly but if you want a rule to
create a new resource you have two choices - create a blank node or
create a URI node with some synthesized URI. See makeTemp & makeSkolem
for the first case, see uriConcat for the second.
Be careful that don't end up with a rule which will keep matching on its
own results and creating an unbounded number of new resources.
Dave