Coder Social home page Coder Social logo

Comments (3)

James-Hudson3010 avatar James-Hudson3010 commented on May 20, 2024

I believe I understand part of what is going on, but not the reasons behind it.

When one splits into three separate parts, the shacl_graph does not contain the ont_graph information and cannot be processed correctly.

A simple hack that fixes the problem is one line of code in the Validator __init__ code.

shacl_graph = mix_datasets( shacl_graph, self.ont_graph )

        if self.ont_graph is not None and \
            isinstance(self.ont_graph, (rdflib.Dataset, rdflib.ConjunctiveGraph)):
            self.ont_graph.default_union = True

       shacl_graph = mix_datasets( shacl_graph, self.ont_graph )

        if shacl_graph is None:
            shacl_graph = clone_graph(data_graph, identifier='shacl')
        assert isinstance(shacl_graph, rdflib.Graph),\
            "shacl_graph must be a rdflib Graph object"
        self.shacl_graph = ShapesGraph(shacl_graph, self.logger)

basically, I add the ont_graph to the shacl_graph and it works as expected.

Obviously, there are some more checks that need to go in here for a complete solution and there may be other issues I have not yet considered.

from pyshacl.

ashleysommer avatar ashleysommer commented on May 20, 2024

Hi @James-Hudson3010

Yes, your assessment is correct, in pySHACL the shacl_graph does not get any ont_graph triples mixed in.
Keep in mind the extra-ontology-graph feature (ont_graph) was specifically introduced to mix into the DataGraph for the purpose to keep DataGraph files smaller, and the practical reality that DataGraph files cannot always be relied on to contain all of the ontology definitions required for validation to work properly, especially if the Datagraph was supposed to be pre-inferenced before validation and those definitions are needed to enable inferencing.

The ont_graph was never intended to mix with the SHACL Shapes Graph. Its considered bad practice for a shacl validator to modify the Shapes graph in any way before validation, because that can cause unforeseen validation issues (as you have alluded to).

If a SHACL Shapes Graph requires any ontological definitions in order to work correctly then it makes sense that the author should include those definitions either directly in the SHACL Shapes source file, or via an owl:imports statement in the SHACL shapes file.

I hope that has helped.

from pyshacl.

James-Hudson3010 avatar James-Hudson3010 commented on May 20, 2024

It does. Thank you.

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.