Skip to content

Commit

Permalink
Empowered NegativeAssertion validation with clearer message
Browse files Browse the repository at this point in the history
  • Loading branch information
mdesalvo committed Dec 5, 2020
1 parent 0ee9bf0 commit 6908946
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions RDFSharp/Semantics/OWL/Validator/RDFOntologyValidatorRuleset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -941,30 +941,32 @@ internal static RDFOntologyValidatorReport NegativeAssertions(RDFOntology ontolo
.AddFact((RDFOntologyFact)negativeAssertion.TaxonomyObject);

//Check if negative assertion is violated by any existing assertions
if (ontology.Data.Relations.Assertions.Any(asn => compatibleSubjects.Any(subj => subj.Equals(asn.TaxonomySubject))
&& compatibleProperties.Any(pred => pred.Equals(asn.TaxonomyPredicate))
&& compatibleObjects.Any(obj => obj.Equals(asn.TaxonomyObject))))
var violatingAssertions = ontology.Data.Relations.Assertions.Where(asn => compatibleSubjects.Any(subj => subj.Equals(asn.TaxonomySubject))
&& compatibleProperties.Any(pred => pred.Equals(asn.TaxonomyPredicate))
&& compatibleObjects.Any(obj => obj.Equals(asn.TaxonomyObject)));
if (violatingAssertions.Any())
{
report.AddEvidence(new RDFOntologyValidatorEvidence(
RDFSemanticsEnums.RDFOntologyValidatorEvidenceCategory.Error,
"NegativeAssertions",
String.Format("Violation of negative assertion '{0}'.", negativeAssertion),
String.Format("Review negative assertion '{0}' because ontology data contains at least one assertion (maybe an A-BOX inference) violating it.", negativeAssertion)
String.Format("Review negative assertion '{0}' because ontology data contains assertion '{1}' violating it (this may be an inference).", negativeAssertion, violatingAssertions.First())
));
}
}
else
{
//Check if negative assertion is violated by any existing assertions
if (ontology.Data.Relations.Assertions.Any(asn => compatibleSubjects.Any(subj => subj.Equals(asn.TaxonomySubject))
&& compatibleProperties.Any(pred => pred.Equals(asn.TaxonomyPredicate))
&& negativeAssertion.TaxonomyObject.Equals(asn.TaxonomyObject)))
var violatingAssertions = ontology.Data.Relations.Assertions.Where(asn => compatibleSubjects.Any(subj => subj.Equals(asn.TaxonomySubject))
&& compatibleProperties.Any(pred => pred.Equals(asn.TaxonomyPredicate))
&& negativeAssertion.TaxonomyObject.Equals(asn.TaxonomyObject));
if (violatingAssertions.Any())
{
report.AddEvidence(new RDFOntologyValidatorEvidence(
RDFSemanticsEnums.RDFOntologyValidatorEvidenceCategory.Error,
"NegativeAssertions",
String.Format("Violation of negative assertion '{0}'.", negativeAssertion),
String.Format("Review negative assertion '{0}' because ontology data contains at least one assertion (maybe an A-BOX inference) violating it.", negativeAssertion)
String.Format("Review negative assertion '{0}' because ontology data contains assertion '{1}' violating it (this may be an inference).", negativeAssertion, violatingAssertions.First())
));
}
}
Expand Down

0 comments on commit 6908946

Please sign in to comment.