/// <summary> /// Triggers the execution of the given rule on the given ontology. /// Returns a boolean indicating if new evidences have been found. /// </summary> internal Boolean TriggerRule(String ruleName, RDFOntology ontology, RDFOntologyReasoningReport report) { var reasonerRule = this.SelectRule(ruleName); if (reasonerRule != null) { //Raise launching signal RDFSemanticsEvents.RaiseSemanticsInfo(String.Format("Launching execution of reasoning rule '{0}'", ruleName)); //Launch the reasoning rule var oldCnt = report.EvidencesCount; reasonerRule.ExecuteRule(ontology, report); var newCnt = report.EvidencesCount - oldCnt; //Raise termination signal RDFSemanticsEvents.RaiseSemanticsInfo(String.Format("Completed execution of reasoning rule '{0}': found {1} new evidences", ruleName, newCnt)); return(newCnt > 0); } return(false); }
/// <summary> /// Applies the reasoner on the given ontology, producing a reasoning report. /// The ontology is progressively enriched with discovered inferences. /// </summary> public RDFOntologyReasoningReport ApplyToOntology(RDFOntology ontology) { if (ontology != null) { var rReport = new RDFOntologyReasoningReport(ontology.Value.PatternMemberID); //Step 0: Cleanup ontology from inferences ontology.ClearInferences(); //Step 1: Apply class-based rules this.TriggerRule("EquivalentClassTransitivity", ontology, rReport); this.TriggerRule("SubClassTransitivity", ontology, rReport); this.TriggerRule("DisjointWithEntailment", ontology, rReport); //Step 2: Apply property-based rules this.TriggerRule("EquivalentPropertyTransitivity", ontology, rReport); this.TriggerRule("SubPropertyTransitivity", ontology, rReport); //Step 3: Apply data-based rules this.TriggerRule("SameAsTransitivity", ontology, rReport); this.TriggerRule("DifferentFromEntailment", ontology, rReport); this.TriggerRule("ClassTypeEntailment", ontology, rReport); this.TriggerRule("DomainEntailment", ontology, rReport); this.TriggerRule("RangeEntailment", ontology, rReport); this.TriggerRule("InverseOfEntailment", ontology, rReport); this.TriggerRule("SymmetricPropertyEntailment", ontology, rReport); this.TriggerRule("TransitivePropertyEntailment", ontology, rReport); this.TriggerRule("PropertyEntailment", ontology, rReport); this.TriggerRule("SameAsEntailment", ontology, rReport); //Step 5: Apply custom rules foreach (var sr in this.Rules.Where(r => r.RuleType == RDFSemanticsEnums.RDFOntologyReasoningRuleType.UserDefined)) { this.TriggerRule(sr.RuleName, ontology, rReport); } return(rReport); } throw new RDFSemanticsException("Cannot apply RDFOntologyReasoner because given \"ontology\" parameter is null."); }