Using Jena Rules File on inferred model to create a validator for an ontology

1.2k Views Asked by At

What I want to do: Create a validator for an ontology in Java. For this I want to use Jena Rules on a inferred model. Unfortunately I can't use both the standard reasoner (ReasonerRegistry.getOWLReasoner()) and after this my own reasoner (new GenericRuleReasoner(Rule.rulesFromURL("file:rulefile.txt"))). Is this possible somehow?

2

There are 2 best solutions below

0
On BEST ANSWER

The answer from @Joshua is absolutely correct. The only thing you need to know is that you can parse the rdf reasoner to GenericRuleReasoner or the owl reasoner to OWLFBRuleReasoner. From GenericRuleReasoner/OWLFBRuleReasoner you can get the list of the rules. List<Rule> rules = new ArrayList<>((OWLFBRuleReasoner)ReasonerRegistry.getOWLReasoner().getRules()); rules.addAll(Rule.rulesFromURL("file:JENA_RULES_FILE")); GenericRuleReasoner completeReasoner = new GenericRuleReasoner(rules);

2
On

The default ontological reasoning within Jena should provide decent validation of standard owl ontologies. The following explains how to use that same mechansism for domains that may skirt outside of what owl provides.

In order to have domain-specific conflicts be generated when using the GnericRuleReasoner, one needs to stimulate the generation of a domain-specific ValidityReport when FBRuleInfGraph.validate() is called.

This method introduces a triple to the inference graph:

728  Triple validateOn = new Triple(NodeFactory.createAnon(), 
729                          ReasonerVocabulary.RB_VALIDATION.asNode();
730                          Functor.makeFunctorNode("on", new Node[] {}));

The idea behind this is that rules within the domain will be sensitive to the existance of this triple, and then generate a RB_VALIDATE_REPORT when a constraint of the domain fails.

Treating the existing OWL domain as an example of this, we can search for rules that signal a violation of OWL's domains-specific constraints (from etc/owl-fb.rules):

[validationIndiv2: (?v rb:validation on()) (?X owl:disjointWith ?Y) ->
  [validationIndiv: (?I rb:violation error('conflict', 'Individual a member of disjoint classes', ?X, ?Y))
        <- (?I rdf:type ?X), (?I rdf:type ?Y) noValue(?T rb:prototype ?I)] ]

This forward-chaining rule introduces a backward-chaining rule that expresses a rb:violation when an individual is a member of disjoint classes.