Skip to content

Commit

Permalink
FIX turtle problem with axiom annotation IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco authored and Marco committed Jul 27, 2021
1 parent 25e9c33 commit 6d2c97a
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion RDFSharp/Model/Serializers/RDFTurtle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1764,7 +1764,7 @@ private static bool IsLocalEscapedChar(int codePoint)
/// </summary>
private static bool IsBLANK_NODE_LABEL_StartChar(int codePoint)
{
return IsPN_CHARS_U(codePoint) || char.IsNumber((char)codePoint) || codePoint == '-';
return IsPN_CHARS_U(codePoint) || char.IsNumber((char)codePoint);
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion RDFSharp/Semantics/OWL/Ontology/Data/RDFOntologyData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1136,7 +1136,7 @@ public RDFOntologyLiteral SelectLiteral(string literal)
/// Gets the representative of the given taxonomy entry
/// </summary>
internal RDFOntologyFact GetTaxonomyEntryRepresentative(RDFOntologyTaxonomyEntry taxonomyEntry)
=> new RDFOntologyFact(new RDFResource($"bnode:axiom{taxonomyEntry.TaxonomyEntryID}"));
=> new RDFOntologyFact(new RDFResource($"bnode:semref{taxonomyEntry.TaxonomyEntryID}"));
#endregion

#region Set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ public RDFOntologyClass SelectClass(string ontClass)
/// Gets the representative of the given taxonomy entry
/// </summary>
internal RDFOntologyFact GetTaxonomyEntryRepresentative(RDFOntologyTaxonomyEntry taxonomyEntry)
=> new RDFOntologyFact(new RDFResource($"bnode:axiom{taxonomyEntry.TaxonomyEntryID}"));
=> new RDFOntologyFact(new RDFResource($"bnode:semref{taxonomyEntry.TaxonomyEntryID}"));
#endregion

#region Set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,7 @@ public RDFOntologyProperty SelectProperty(string ontProperty)
/// Gets the representative of the given taxonomy entry
/// </summary>
internal RDFOntologyFact GetTaxonomyEntryRepresentative(RDFOntologyTaxonomyEntry taxonomyEntry)
=> new RDFOntologyFact(new RDFResource($"bnode:axiom{taxonomyEntry.TaxonomyEntryID}"));
=> new RDFOntologyFact(new RDFResource($"bnode:semref{taxonomyEntry.TaxonomyEntryID}"));
#endregion

#region Set
Expand Down
15 changes: 8 additions & 7 deletions RDFSharp/Semantics/OWL/Ontology/RDFOntologyHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2031,17 +2031,18 @@ void BuildSemanticReification(bool isAxiomAnn, RDFOntologyTaxonomyEntry te, RDFT
RDFResource type, RDFResource subjProp, RDFResource predProp, RDFResource objProp, RDFResource litProp)
{
//Reification
result.AddTriple(new RDFTriple(asnTriple.ReificationSubject, RDFVocabulary.RDF.TYPE, type));
result.AddTriple(new RDFTriple(asnTriple.ReificationSubject, subjProp, (RDFResource)asnTriple.Subject));
result.AddTriple(new RDFTriple(asnTriple.ReificationSubject, predProp, (RDFResource)asnTriple.Predicate));
RDFResource axiomRepresentative = new RDFResource(asnTriple.ReificationSubject.ToString().Replace("bnode:", "bnode:semref"));
result.AddTriple(new RDFTriple(axiomRepresentative, RDFVocabulary.RDF.TYPE, type));
result.AddTriple(new RDFTriple(axiomRepresentative, subjProp, (RDFResource)asnTriple.Subject));
result.AddTriple(new RDFTriple(axiomRepresentative, predProp, (RDFResource)asnTriple.Predicate));
if (asnTriple.TripleFlavor == RDFModelEnums.RDFTripleFlavors.SPL)
result.AddTriple(new RDFTriple(asnTriple.ReificationSubject, litProp, (RDFLiteral)asnTriple.Object));
result.AddTriple(new RDFTriple(axiomRepresentative, litProp, (RDFLiteral)asnTriple.Object));
else
result.AddTriple(new RDFTriple(asnTriple.ReificationSubject, objProp, (RDFResource)asnTriple.Object));
result.AddTriple(new RDFTriple(axiomRepresentative, objProp, (RDFResource)asnTriple.Object));

//AxiomAnnotation
if (isAxiomAnn)
result.AddTriple(new RDFTriple(asnTriple.ReificationSubject, (RDFResource)te.TaxonomyPredicate.Value, (RDFLiteral)te.TaxonomyObject.Value));
result.AddTriple(new RDFTriple(axiomRepresentative, (RDFResource)te.TaxonomyPredicate.Value, (RDFLiteral)te.TaxonomyObject.Value));
};

//Finds the taxonomy entry represented by the given ID in the ontology taxonomies
Expand Down Expand Up @@ -2102,7 +2103,7 @@ RDFOntologyTaxonomyEntry FindTaxonomyEntry(long teID)
//In case of owl:Axiom, we have to lookup the linked taxonomy entry by ID
if (isAxiomAnnotation)
{
string teID = te.TaxonomySubject.ToString().Replace("bnode:axiom", string.Empty);
string teID = te.TaxonomySubject.ToString().Replace("bnode:semref", string.Empty);
RDFOntologyTaxonomyEntry axiomAsn = FindTaxonomyEntry(long.Parse(teID));
if (axiomAsn == null)
continue;
Expand Down

0 comments on commit 6d2c97a

Please sign in to comment.