mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-03 15:01:00 +02:00
Fix/extraction prov (#662)
Quoted triple fixes, including...
1. Updated triple_provenance_triples() in triples.py:
- Now accepts a Triple object directly
- Creates the reification triple using TRIPLE term type: stmt_uri tg:reifies
<<extracted_triple>>
- Includes it in the returned provenance triples
2. Updated definitions extractor:
- Added imports for provenance functions and component version
- Added ParameterSpec for optional llm-model and ontology flow parameters
- For each definition triple, generates provenance with reification
3. Updated relationships extractor:
- Same changes as definitions extractor
This commit is contained in:
parent
cd5580be59
commit
2b9232917c
19 changed files with 361 additions and 72 deletions
|
|
@ -26,8 +26,40 @@ KEYWORD = 'https://schema.org/keywords'
|
|||
class Uri(str):
|
||||
def is_uri(self): return True
|
||||
def is_literal(self): return False
|
||||
def is_triple(self): return False
|
||||
|
||||
class Literal(str):
|
||||
def is_uri(self): return False
|
||||
def is_literal(self): return True
|
||||
def is_triple(self): return False
|
||||
|
||||
class QuotedTriple:
|
||||
"""
|
||||
RDF-star quoted triple (reification).
|
||||
|
||||
Represents a triple that can be used as the object of another triple,
|
||||
enabling statements about statements.
|
||||
|
||||
Example:
|
||||
# stmt:123 tg:reifies <<:Hope skos:definition "A feeling...">>
|
||||
qt = QuotedTriple(
|
||||
s=Uri("https://example.org/Hope"),
|
||||
p=Uri("http://www.w3.org/2004/02/skos/core#definition"),
|
||||
o=Literal("A feeling of expectation")
|
||||
)
|
||||
"""
|
||||
def __init__(self, s, p, o):
|
||||
self.s = s # Uri, Literal, or QuotedTriple
|
||||
self.p = p # Uri
|
||||
self.o = o # Uri, Literal, or QuotedTriple
|
||||
|
||||
def is_uri(self): return False
|
||||
def is_literal(self): return False
|
||||
def is_triple(self): return True
|
||||
|
||||
def __repr__(self):
|
||||
return f"<<{self.s} {self.p} {self.o}>>"
|
||||
|
||||
def __str__(self):
|
||||
return f"<<{self.s} {self.p} {self.o}>>"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue