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 
<[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


Reply via email to