Without inference during validation the triple is inferred in my environment too. Thank you.
On Thursday, May 27, 2021 at 8:07:30 AM UTC+2 [email protected] wrote: > Thank you Boris. I'll have a look. > > On Thursday, May 27, 2021 at 2:54:55 AM UTC+2 Boris Pelakh wrote: > >> When I run your code, among the several triples added I see >> >> (rdflib.term.URIRef('http://example.org#Avatar'), rdflib.term.URIRef(' >> http://schema.org/keyWords'), rdflib.term.URIRef('http://example.org#Sam' >> )) >> >> If you turn off inference, it is the only triple added. So perhaps some >> sort of an environment issue. >> >> On Wed, May 26, 2021 at 1:24 PM [email protected] < >> [email protected]> wrote: >> >>> A new conversation because I can not add a new to the previous. >>> >>> @Boris, Yes, sometimes even inference within TB Composer is complex. >>> >>> So I hoped pyshacl is an alternative. But a minimal running example does >>> not give inferred triples; sorry to be a hard learner. Here I try to infer >>> keyWords for schema:Avatar. >>> >>> Python code >>> --------------------------------------------------------------------- >>> from rdflib import Graph, URIRef >>> from pyshacl import validate >>> >>> shapes = Graph() >>> shapes.parse('testshapes.ttl', format='ttl') >>> data_graph = Graph() >>> data_graph.parse('testdata.ttl', format='ttl') >>> >>> data_graph_orig = Graph() >>> for t in data_graph: >>> data_graph_orig.add(t) >>> >>> r = validate(data_graph, >>> shacl_graph=shapes, >>> #ont_graph=og, >>> inference='rdfs', >>> abort_on_error=False, >>> meta_shacl=True, >>> advanced=True, >>> js=False, >>> debug=True) >>> >>> conforms, results_graph, results_text = r >>> >>> added_triples = data_graph - data_graph_orig >>> print('Added triples: ', len(added_triples)) >>> print(added_triples.all_nodes()) >>> >>> >>> Data >>> ----------------------------------------------------- >>> @prefix schema: <http://schema.org/> . >>> @prefix owl: <http://www.w3.org/2002/07/owl#> . >>> @prefix : <http://example.org#>. >>> >>> :movies a owl:Ontology ; >>> owl:imports schema: . >>> >>> :Avatar a schema:Movie ; >>> schema:actor :Sam . >>> >>> >>> >>> Shapes: >>> ------------------------------------------------------ >>> @prefix sh: <http://www.w3.org/ns/shacl#>. >>> @prefix owl: <http://www.w3.org/2002/07/owl#> . >>> @prefix schema: <http://schema.org/> . >>> @prefix xsd: <http://www.w3.org/2001/XMLSchema#>. >>> @prefix : <http://example.org#>. >>> >>> :movieOntology >>> a owl:Ontology ; >>> owl:imports schema: ; >>> owl:imports sh: ; >>> owl:imports xsd: ; >>> sh:declare >>> [ sh:prefix "sh" ; >>> sh:namespace "http://www.w3.org/ns/shacl#"^^xsd:anyURI ; ] , >>> [ sh:prefix "schema" ; >>> sh:namespace "http://schema.org/"^^xsd:anyURI ;] , >>> [ sh:prefix "owl" ; >>> sh:namespace "http://www.w3.org/2002/07/owl#"^^xsd:anyURI ; ] >>> . >>> >>> :keywordsRule >>> a sh:NodeShape ; >>> sh:targetClass schema:Movie ; >>> sh:rule [ >>> a sh:SPARQLRule ; >>> sh:prefixes schema: ; >>> sh:construct """ >>> CONSTRUCT { >>> $this schema:keyWords ?actor . >>> } >>> WHERE { >>> $this schema:actor ?actor . >>> } >>> """ ; >>> ] ; >>> . >>> >>> >>> 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/15aef451-28f3-4501-872a-9ae2ca5193d2n%40googlegroups.com >>> >>> <https://groups.google.com/d/msgid/rdflib-dev/15aef451-28f3-4501-872a-9ae2ca5193d2n%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/89ddcb60-2fd9-4672-8b29-b619792e8bdan%40googlegroups.com.
