mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-16 16:51:02 +02:00
Unique IDs
This commit is contained in:
parent
9fd16cbae8
commit
2a4b4d5c18
1 changed files with 7 additions and 12 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue