Skip to content

Commit

Permalink
FIX ToString of atoms
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco authored and Marco committed Jul 16, 2021
1 parent 64969da commit 56d760b
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ internal RDFOntologyReasonerRuleAtom(RDFOntologyResource predicate, RDFPatternMe
{
if (predicate == null)
throw new RDFSemanticsException("Cannot create atom because given \"predicate\" parameter is null");

if (leftArgument == null)
throw new RDFSemanticsException("Cannot create atom because given \"leftArgument\" parameter is null");

Expand All @@ -82,12 +81,15 @@ public override string ToString()
sb.Append($"({this.LeftArgument}");
if (this.RightArgument != null)
{
//When the right argument is a fact, it is printened in a SWRL-shortened form
if (this.RightArgument is RDFOntologyFact rightArgumentFact)
sb.Append($",{RDFModelUtilities.GetShortUri(((RDFResource)rightArgumentFact.Value).URI)}");
//When the right argument is an ontology literal, its value is printed in normal form
else if (this.RightArgument is RDFOntologyLiteral rightArgumentLiteral)
sb.Append($",{RDFQueryPrinter.PrintPatternMember(rightArgumentLiteral.Value, RDFNamespaceRegister.Instance.Register)}");
else if (this.RightArgument is RDFVariable rightArgumentVariable)
sb.Append($",{RDFQueryPrinter.PrintPatternMember(rightArgumentVariable, RDFNamespaceRegister.Instance.Register)}");
//Other cases of right argument (variable, plain/typed literal) are printed in normal form
else
sb.Append($",{RDFQueryPrinter.PrintPatternMember(this.RightArgument, RDFNamespaceRegister.Instance.Register)}");
}
sb.Append(")");

Expand Down

0 comments on commit 56d760b

Please sign in to comment.