RDFLib / pySHACL

A Python validator for SHACL
Apache License 2.0
241 stars 63 forks source link

Generating SHACL-SPARQL shapes in RDFLib #207

Closed AJAY31797 closed 9 months ago

AJAY31797 commented 9 months ago

Hi,

I am trying to validate a data graph against a shapes graph using pySHACL. I have the data graph exported from the IFCtoLBD converter, stored as a '.ttl' file in my system, which I have imported for validation. However, I need to develop the shapes graph on my own. I am unsure how to generate a SHACL-SPARQL shape graph in the RDFLib. I want to generate the graph in the Turtle format. Can anyone suggest how to do it? I went through the documentation of RDFLib, but to my understanding, it provides only the capability to add the triples and query them. However, I could not find anything related to creating a SHACL-SPARQL shapes graph, which needs a combination of triples as well as SPARQL query. Can we simply write the graph within triple quotation marks and serialize it as 'ttl'? I am new to RDFLib. Any help is much appreciated.

Thanks.

ashleysommer commented 9 months ago

Hi @AJAY31797 This is an RDFLib basic use question, not related the usage of PySHACL, so should not be in the PySHACL issue tracker.

However, to answer your question, please see the examples in this repo for how to parse literal ttl strings into an RDFLib graph. Eg, https://github.com/RDFLib/pySHACL/blob/master/examples/two_file_example.py

Also all of the files under test/issues/ will contain lots of ways of using RDFLib to drive PySHACL. Eg: https://github.com/RDFLib/pySHACL/tree/master/test/issues

AJAY31797 commented 9 months ago

Hi @ashleysommer, Thanks a lot for your response.

Best Regards, Ajay