-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposed enhancement - iterative rule evaluation #76
Comments
@ashleysommer I will be submitting a PR for this in the next couple of days. Do you feel this needs a flag in |
Hi @sa-bpelakh Theres also different ways this could be implemented. Eg, iterative rule evaluation could iteratively execute the ordered Additionally, there would need to be mitigations in place to protect against infinite loops, and potentially infinite depth recursion. |
I've been doing some experimentation and testing on my local copy of PySHACL to see how hard this will be for you to implement. You could do a count of triples in the graph before the CONSTRUCT, then another count after executing, but that is generally a bad idea. If the graph is not an in-memory graph, or the graph contains billions of triples, rdflib can blow out the system memory or crash entirely when trying to count the triples in the graph. |
My previous comment is partially incorrect. After doing some more research, the RDFLib Construct statement does give access to the new triples created (before they are mixed into the data_graph). However we'd still need to check if every triple in the new construct graph is already in the data_graph (before adding it) to determine if we're in steady state. |
…ly execute until the data_graph reaches a steady state. This works on SPARQL Rules, Triple Rules, and JS Rules. Closes #76
@sa-bpelakh |
@ashleysommer It's all good, it was interesting to compare your implementation to the one I had working. I will leave a comment on the PR. |
…ly execute until the data_graph reaches a steady state. This works on SPARQL Rules, Triple Rules, and JS Rules. Closes #76
Add the ability for SHACL rules to operate iteratively. Closes #76
Update, almost a year later. I realized my testing of this issue was not quite right. Firstly: Secondly, the example uses the "sh:prefixes" feature incorrectly. All prefixes listed on a SPARQLRule using the Fixing these two issues uncovered a small inconsistency in my implementation of the feature #77. I've fixed that, and a new version with corrected test and corrected feature will be released shortly. |
Added more type hinting, to conform to the new type hinting added by RDFLib 6.1.1 Subtle correction in the way `sh:prefixs` works with `sh:declare` on the given named ontology. Bumped some min versions of libraries, to gain compatibility with Python 3.10 Fixed test for issue #76 Fixed #76 again (after fixed test) Bumped Version v0.18.0
Currently rule evaluation is single pass, so even if triples asserted during evaluation could trigger the execution of additional rules, those triggers don't occur. For example, here is a set of rules which attaches a
:hasDepth
to everyConcept
in a SKOS taxonomy indicating its distance from theConceptScheme
:Without iterative evaluation of rules, no concepts past the direct
skos:narrower
of the top concepts are guaranteed to receive a depth.The proposal is to track whether new triples were added to the data graph during rule execution, and if so, iterate through the rules again until a stable state is reached. This is the default functionality of the TopBraid rule engine.
The text was updated successfully, but these errors were encountered: