Code Monkey home page Code Monkey logo

Comments (6)

ashleysommer avatar ashleysommer commented on June 12, 2024

Hi @RanjithSoman
When I first read this, I assumed you were seeing the same issue as reported here:
#6

But looking at it again, I think this is something different.

The interesting thing is that if you put your Shapes file and Data file as separate snippets into the SHACL playground, which uses a completely separate and independent shacl implementation, you get the same results: http://shacl.org/playground/
But this might be just because SHACL-JS (used in shacl playground) does not do any inferencing on the datagraph at all.

So this is probably a bug in pySHACL.

The SHACL test suite (which pySHACL is tested against and passes) uses test cases that are in 99% of cases a combined SHACL file and Data file. So cases where the SHACL shapes file and target data file are separate are not thoroughly tested. You might have found a case where a SPARQL-constraint in the Shacl Shapes file is not being applied correctly to the data graph in the target file.

I will need to hook this up to the debugger and step through the validation process to find out what is going on here.

from pyshacl.

ranjithksoman avatar ranjithksoman commented on June 12, 2024

SHACL playground doesn't support SHACL SPARQL at the moment.
I believe there is a bug in the pySHACL. However, I am new to SHACL and I not fully confident about how my shape data is structured too.

from pyshacl.

ashleysommer avatar ashleysommer commented on June 12, 2024

@RanjithSoman
I've found the problem.
See in the combined file, your NodeShape has ID: Testsparql:Process.
There are no target classes defined on the NodeShape, and the shape is subclass of rdfs:Class, so the Nodeshape Testsparql:Process becomes an "Implicit Target Class", therefore this shacl shape applies validation to all classes in the datagraph that are instances of type Testsparql:Process. Which is (I think) your intention. And you see a correct result.

However looking at the split files example, in your SHACL Shape graph file you have renamed the NodeShape to have ID Testsparql:Processshape. Again, there are no target classes defined, and the shape is still subclass of rdfs:Class. So again, this NodeShape becomes an "Implicit Target Class", and will apply validation to all classes in the datagraph that are instances of type Testsparql:Processshape. But the Process instances in the datagraph file are of type Testsparql:Process, so none of them get the rule applied to them.

In short: Changing the ID of Testsparql:Processshape in the SHACL Shape file to Testsparql:Process fixes your problem.

from pyshacl.

ashleysommer avatar ashleysommer commented on June 12, 2024

@RanjithSoman
UNRELATED to this issue:
I noticed your split file example, you have an ontology declaration in the datagraph file. That ontology declaration includes a sh:declares predicate which points to the PrefixDeclaration in the SHACL Shapes file.
I think this whole ontology declaration should go into the SHACL Shapes file, rather in the datafile.

  1. Because a target datagraph is not usually itself an ontology (but sometimes can be)
  2. The ID of the subject of the ontology declaration is <http://semanticprocess.x10host.com/Ontology/Testsparql>, I think that is the name of the SHACL file, not the datagraph file. Declaring it in the datafile means the SHACL shapes graph does not know about that declaration.
  3. The sh:declares predicate points to Testsparql:PrefixDeclaration which is a node in the SHACL shapes graph. The datagraph does not join with the shacl shapes graph, so this triple does nothing.
  4. In the shacl shapes graph, the Testsparql:Processshape has a sh:shacl rule that includes sh:prefix of the ID of the ontology declaration. But the sh:prefix predicate can only find prefix IDs of nodes that are declared in the SHACL Shapes file. So it won't see it.

In short: Maybe you just made a copy/paste mistake when splitting the files, but the ontology declaration you have put in the datagraph file should be in the shacl shapes file.

But in this case that does not change the outcome of the validation. For some reason a working sh:declares and sh:prefix combo is not required in order for this sh:shacl rule to complete correctly. Might have something to do with the implicit prefix binding that pyshacl does when loading RDF graphs.

from pyshacl.

ashleysommer avatar ashleysommer commented on June 12, 2024

@RanjithSoman Please close this issue if your problem is solved.

from pyshacl.

ranjithksoman avatar ranjithksoman commented on June 12, 2024

@ashleysommer Thank you for the clarification. Much appreciated.

from pyshacl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.