mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-16 16:51:02 +02:00
Building document metadata
This commit is contained in:
parent
33a4647155
commit
9a5cd8b86e
2 changed files with 62 additions and 4 deletions
|
|
@ -1,10 +1,16 @@
|
||||||
|
|
||||||
from pulsar.schema import Record, String
|
from pulsar.schema import Record, String, Array
|
||||||
|
from . types import Triple
|
||||||
|
|
||||||
class Metadata(Record):
|
class Metadata(Record):
|
||||||
source = String()
|
|
||||||
|
# Source identifier
|
||||||
id = String()
|
id = String()
|
||||||
title = String()
|
|
||||||
|
# Subgraph
|
||||||
|
source = Array(Triple())
|
||||||
|
|
||||||
|
# Collection management
|
||||||
user = String()
|
user = String()
|
||||||
collection = String()
|
collection = String()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,11 @@ class Loader:
|
||||||
path = file
|
path = file
|
||||||
data = open(path, "rb").read()
|
data = open(path, "rb").read()
|
||||||
|
|
||||||
id = hashlib.sha256(path.encode("utf-8")).hexdigest()[0:8]
|
# 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]))
|
||||||
|
|
||||||
r = Document(
|
r = Document(
|
||||||
metadata=Metadata(
|
metadata=Metadata(
|
||||||
|
|
@ -112,6 +116,54 @@ def main():
|
||||||
help=f'Collection ID (default: {default_collection})'
|
help=f'Collection ID (default: {default_collection})'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
'--name', help=f'Document name'
|
||||||
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
'--description', help=f'Document description'
|
||||||
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
'--copyright-notice', help=f'Copyright notice'
|
||||||
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
'--copyright-holder', help=f'Copyright holder'
|
||||||
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
'--copyright-year', help=f'Copyright year'
|
||||||
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
'--licence', help=f'Copyright licence'
|
||||||
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
'--publication-organization', help=f'Publication organization'
|
||||||
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
'--publication-description', help=f'Publication description'
|
||||||
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
'--publication-date', help=f'Publication date'
|
||||||
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
'--url', help=f'Document URL'
|
||||||
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
'--keyword', help=f'Keyword'
|
||||||
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
'--title', help=f'Document title'
|
||||||
|
)
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-l', '--log-level',
|
'-l', '--log-level',
|
||||||
type=LogLevel,
|
type=LogLevel,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue