mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-17 01:01:03 +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
|
return id
|
||||||
|
|
||||||
|
def curi(pref, id):
|
||||||
|
return f"https://trustgraph.ai/{pref}/{id}"
|
||||||
|
|
||||||
class DigitalDocument:
|
class DigitalDocument:
|
||||||
def __init__(
|
def __init__(
|
||||||
self, id, name=None, description=None, copyright_notice=None,
|
self, id, name=None, description=None, copyright_notice=None,
|
||||||
|
|
@ -75,16 +78,6 @@ class DigitalDocument:
|
||||||
self.identifier = identifier
|
self.identifier = identifier
|
||||||
self.keywords = keywords
|
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):
|
def emit(self, emit):
|
||||||
|
|
||||||
emit(self.id, IS_A, DIGITAL_DOCUMENT)
|
emit(self.id, IS_A, DIGITAL_DOCUMENT)
|
||||||
|
|
@ -217,6 +210,8 @@ class Loader:
|
||||||
# Convert into a UUID, 64-byte hash becomes 32-byte UUID
|
# Convert into a UUID, 64-byte hash becomes 32-byte UUID
|
||||||
id = str(uuid.UUID(id[::2]))
|
id = str(uuid.UUID(id[::2]))
|
||||||
|
|
||||||
|
id = curi("doc", id)
|
||||||
|
|
||||||
triples = []
|
triples = []
|
||||||
|
|
||||||
def emit(s, p, o):
|
def emit(s, p, o):
|
||||||
|
|
@ -367,11 +362,11 @@ def main():
|
||||||
|
|
||||||
if args.publication_organization:
|
if args.publication_organization:
|
||||||
org = Organization(
|
org = Organization(
|
||||||
id=hash(args.publication_organization),
|
id=curi("org", hash(args.publication_organization)),
|
||||||
name=args.publication_organization,
|
name=args.publication_organization,
|
||||||
)
|
)
|
||||||
document.publication = PublicationEvent(
|
document.publication = PublicationEvent(
|
||||||
id = str(uuid.uuid4()),
|
id = curi("pubev", str(uuid.uuid4())),
|
||||||
organization=org,
|
organization=org,
|
||||||
description=args.publication_description,
|
description=args.publication_description,
|
||||||
start_date=args.publication_date,
|
start_date=args.publication_date,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue