Closed kotlenik closed 7 years ago
Yes, I expect the SHACL rules feature to be more useful than pure constraints for many use cases. It didn't get into the main document of SHACL because the WG was not chartered to look into rules even though the interest was always there.
In terms of examples, the RuleUtil class is hopefully easy enough to use but SHACL files are in the test cases, e.g. https://github.com/TopQuadrant/shacl/tree/master/src/test/resources/sh/tests/rules (I notice that the TestCaseType for these is currently not part of the open source code base but it call the same RuleUtil method). What specific question do you have?
Hi Holger!
Thanks for your fast reply.
System we are working on deals with large amount of biomedical data. For some triples,
regarding patients, if specific values are found, we must infer some new triples, initially
not found in source data. Therefore example in docs (inferring Square instance from specific
Rectangle instance) almost completely cover our case.
But, when I coded this simple example, I was'n able to reach inferred instances and to serialize
them to some RDF file. Here is code sample:
_Model dataModel = JenaUtil.createMemoryModel();
dataModel.read(new FileInputStream("/some/path/rule_and_data_integral.ttl"), "urn:dummy", FileUtils.langTurtle);
Model processed = RuleUtil.executeRules(dataModel, dataModel, null, new NullProgressMonitor());
processed.write(new FileOutputStream("processed.ttl"));_
Can you give me some guidance if I am using RuleUtil in wrong way, or if I made some
other mistake? What I get is an empty RDF file. I use identical data in file like on docs page.
Regards,
Adam
Hmm, hard to say. You may want to step this through in a debugger. The first question is whether the first few lines of RuleUtil are executed correctly - your shapes graph does not include the SHACL/DASH system namespaces which are needed at runtime. So the first if should add these. Once this has been made sure, I guess you could step through the code to see which rules are detected (RuleEngine.executeAll() -> check size of ruleShapes).
Thanks for hint! I'll try that.
Hi! While developing simple custom based RDF validation library using your SHACL implementation, on docs page I found https://www.w3.org/TR/shacl-af/#rules , which is also incredibly useful for some custom based RDF investigation scenarios. Is there any examples for usage of sh:rule with RuleUtil.executeRules? Thanks! Adam