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 <[email protected]>
À : "[email protected]" <[email protected]>
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
<[email protected]> 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 <[email protected]>
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