mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-23 20:21:03 +02:00
Changed schema for Value -> Term, majorly breaking change
This commit is contained in:
parent
e061f2c633
commit
1c408a882f
1 changed files with 43 additions and 6 deletions
|
|
@ -1,22 +1,59 @@
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
|
|
||||||
|
# Term type constants
|
||||||
|
IRI = "i" # IRI/URI node
|
||||||
|
BLANK = "b" # Blank node
|
||||||
|
LITERAL = "l" # Literal value
|
||||||
|
TRIPLE = "t" # Quoted triple (RDF-star)
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Error:
|
class Error:
|
||||||
type: str = ""
|
type: str = ""
|
||||||
message: str = ""
|
message: str = ""
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Value:
|
class Term:
|
||||||
|
"""
|
||||||
|
RDF Term - can represent an IRI, blank node, literal, or quoted triple.
|
||||||
|
|
||||||
|
The 'type' field determines which other fields are relevant:
|
||||||
|
- IRI: use 'iri' field
|
||||||
|
- BLANK: use 'id' field
|
||||||
|
- LITERAL: use 'value', 'datatype', 'language' fields
|
||||||
|
- TRIPLE: use 'triple' field
|
||||||
|
"""
|
||||||
|
type: str = "" # One of: IRI, BLANK, LITERAL, TRIPLE
|
||||||
|
|
||||||
|
# For IRI terms (type == IRI)
|
||||||
|
iri: str = ""
|
||||||
|
|
||||||
|
# For blank nodes (type == BLANK)
|
||||||
|
id: str = ""
|
||||||
|
|
||||||
|
# For literals (type == LITERAL)
|
||||||
value: str = ""
|
value: str = ""
|
||||||
is_uri: bool = False
|
datatype: str = "" # XSD datatype URI (mutually exclusive with language)
|
||||||
type: str = ""
|
language: str = "" # Language tag (mutually exclusive with datatype)
|
||||||
|
|
||||||
|
# For quoted triples (type == TRIPLE)
|
||||||
|
triple: Triple | None = None
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Triple:
|
class Triple:
|
||||||
s: Value | None = None
|
"""
|
||||||
p: Value | None = None
|
RDF Triple / Quad.
|
||||||
o: Value | None = None
|
|
||||||
|
The optional 'g' field specifies the named graph (None = default graph).
|
||||||
|
"""
|
||||||
|
s: Term | None = None # Subject
|
||||||
|
p: Term | None = None # Predicate
|
||||||
|
o: Term | None = None # Object
|
||||||
|
g: str | None = None # Graph name (IRI), None = default graph
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Field:
|
class Field:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue