Hi Boris,

Thank you for fixing the errors and showing how pyshacl can do it.

The shapes do come from the TopQuadrant site: 
https://www.topquadrant.com/graphql/values.html , expecting that these 
would run for sure. 
This explains the spif class .

Kind regards,
Richard

On Friday, May 21, 2021 at 2:00:32 PM UTC+2 Boris Pelakh wrote:

> Took a look at your code and shapes, had to make a couple of little fixes. 
> In your prologue, you had:
>
> data_graph_orig = data_graph
>
> That made them both reference the same graph, so there was never a 
> difference. I replaced that with:
>
> data_graph_orig = Graph()
> for t in data_graph:
>     data_graph_orig.add(t)
>
> to clone the data. That made the extra triples introduced by RDFS 
> reasoning show up as added. I then took a look
> at your shapes, and was a little thrown off by the sh:values construct you 
> used (I can't find it in SHACL-AF) and the
> use of the spif: time functions, which are not natively present in pySHACL 
> (perhaps you introduced them in your
> context?). Regardless, I added the following declaration and rule:
>
> kennedys:
> a owl:Ontology ;
> owl:imports sh: ;
> sh:declare [
> sh:prefix "kennedys" ;
> sh:namespace "http://kennedys.com/"^^xsd:anyURI ;
> ] ;
> sh:declare [
> sh:prefix "schema" ;
> sh:namespace "http://schema.org/"^^xsd:anyURI ;
> ] .
>
> schema:PersonAgeRule
> a sh:NodeShape ;
> sh:targetClass schema:Person ;
> sh:rule [
> a sh:SPARQLRule ;
> sh:prefixes schema: ;
> sh:construct """
> CONSTRUCT {
> $this schema:age ?age
> }
> WHERE {
> $this schema:birthDate ?birthDate .
> FILTER NOT EXISTS { $this schema:deathDate ?any }
> bind(year(now()) - year(xsd:dateTime(CONCAT(STR(?birthDate), 
> 'T00:00:00'))) as ?age)
> }
> """ ;
> ] ;
> .
>
> (The actual YEAR() function only works on dateTime, thus the date hackery)
>
> which caused the following to show up in the graph diff:
>
> (rdflib.term.URIRef('http://kennedys.com/CarolineKennedy'), 
> rdflib.term.URIRef('http://schema.org/age'), rdflib.term.Literal('64', 
> datatype=rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#integer')))
>
> Hope that helps.
> On Friday, May 21, 2021 at 2:54:02 AM UTC-4 [email protected] wrote:
>
>> Thank you Boris for the hint. 
>>
>> Inferences going into the datagraph makes sense indeed. However attached 
>> example does not give the wanted result.
>> I will check this in the weekend again.
>>
>> btw I am running on Windows10 using RDFlib 5.0.0
>>
>> Kind regards,
>> Richard
>>
>> On Thursday, May 20, 2021 at 7:50:17 PM UTC+2 Boris Pelakh wrote:
>>
>>> Richard,
>>>
>>> As per the code, it appears that triples created by inference from 
>>> sh:rule are added into the data_graph, which makes sense, since you can 
>>> evaluate the other rules against the inferred content. In SPARQLRule:
>>>
>>>    data_graph = clone_graph(g, target_graph=data_graph)
>>>
>>> and in TripleRule:
>>>
>>>             for i in iter(new_triples):
>>>                 data_graph.add(i)
>>>
>>> I believe this makes the new triples not accessible from the command 
>>> line at this time, but if you invoke pySHACL from your own main, you should 
>>> be able to inspect the data graph you passed in after running and determine 
>>> the new triples introduced.
>>>
>>> On Thu, May 20, 2021 at 11:55 AM [email protected] <
>>> [email protected]> wrote:
>>>
>>>> Using shacl-af with    pyshacl -a   I want to materialize the inferred 
>>>> triples using shacl-rules.
>>>> It is however not clear to me in what result the triples are collected. 
>>>> Any hint is appreciated.
>>>>
>>>> kind regards, Richard
>>>>
>>>> -- 
>>>> http://github.com/RDFLib
>>>> --- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "rdflib-dev" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>> an email to [email protected].
>>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/rdflib-dev/6cf11681-7896-472c-8237-7a951548e6d0n%40googlegroups.com
>>>>  
>>>> <https://groups.google.com/d/msgid/rdflib-dev/6cf11681-7896-472c-8237-7a951548e6d0n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>>

-- 
http://github.com/RDFLib
--- 
You received this message because you are subscribed to the Google Groups 
"rdflib-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rdflib-dev/c708299c-ecf2-4a6b-9ad0-31e39371a5e8n%40googlegroups.com.

Reply via email to