From 2a4b4d5c187297b273a460a4a697b9e482f645b8 Mon Sep 17 00:00:00 2001 From: Cyber MacGeddon Date: Tue, 22 Oct 2024 22:39:54 +0100 Subject: [PATCH] Unique IDs --- trustgraph-cli/scripts/tg-load-pdf | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/trustgraph-cli/scripts/tg-load-pdf b/trustgraph-cli/scripts/tg-load-pdf index e0c176db..26fcf7eb 100755 --- a/trustgraph-cli/scripts/tg-load-pdf +++ b/trustgraph-cli/scripts/tg-load-pdf @@ -56,6 +56,9 @@ def hash(data): return id +def curi(pref, id): + return f"https://trustgraph.ai/{pref}/{id}" + class DigitalDocument: def __init__( self, id, name=None, description=None, copyright_notice=None, @@ -75,16 +78,6 @@ class DigitalDocument: self.identifier = identifier self.keywords = keywords - # def id_hash(self, data): - - # # Create a SHA256 hash from the data - # id = hashlib.sha256(data).hexdigest() - - # # Convert into a UUID, 64-byte hash becomes 32-byte UUID - # id = str(uuid.UUID(id[::2])) - - # return id - def emit(self, emit): emit(self.id, IS_A, DIGITAL_DOCUMENT) @@ -217,6 +210,8 @@ class Loader: # Convert into a UUID, 64-byte hash becomes 32-byte UUID id = str(uuid.UUID(id[::2])) + id = curi("doc", id) + triples = [] def emit(s, p, o): @@ -367,11 +362,11 @@ def main(): if args.publication_organization: org = Organization( - id=hash(args.publication_organization), + id=curi("org", hash(args.publication_organization)), name=args.publication_organization, ) document.publication = PublicationEvent( - id = str(uuid.uuid4()), + id = curi("pubev", str(uuid.uuid4())), organization=org, description=args.publication_description, start_date=args.publication_date,