public HashSet <Triple> HandleTriplesBeforeHashing(HashSet <Triple> triples) { HashSet <Triple> result = new HashSet <Triple>(); var actualIdsToInternalIds = new Dictionary <string, string>(); foreach (Triple triple in triples) { if (triple.Predicate.Equals(ElephantVocabulary.HasInternalLabel)) { string actualId = triple.Subject.IsBlankNode() ? triple.Subject.AsBlankNode().Identifier : triple.Subject.AsIri().ValueAsString(); string internalId = triple.Object.AsLiteral().LexicalForm; actualIdsToInternalIds.Add(actualId, internalId); } } _logger.LogDebug("actualIdsToInternalIds={0}", actualIdsToInternalIds); foreach (Triple triple in triples) { ISubject subject = triple.Subject; IObject object_ = triple.Object; if (triple.Predicate.Equals(ElephantVocabulary.HasInternalLabel)) { continue; } if (triple.Subject.IsIri() && triple.Subject.AsIri().ValueAsString().StartsWith("urn:")) { subject = new BlankNode(actualIdsToInternalIds[subject.AsIri().ValueAsString()]); result.Add(new Triple(subject, triple.Predicate, object_)); continue; } if (subject.IsBlankNode() || object_.IsBlankNode()) { if (subject.IsBlankNode()) { subject = new BlankNode(actualIdsToInternalIds[subject.AsBlankNode().Identifier]); } if (object_.IsBlankNode()) { object_ = new BlankNode(actualIdsToInternalIds[object_.AsBlankNode().Identifier]); } result.Add(new Triple(subject, triple.Predicate, object_)); } else { result.Add(triple); } } return(result); }