mirror of
https://github.com/semantica-agi/semantica.git
synced 2026-08-29 04:26:20 +00:00
fix(export): handle contextual turtle iris
This commit is contained in:
@@ -516,9 +516,9 @@ class RDFSerializer:
|
||||
rel_type = rel.get("type", DEFAULT_RELATION_TYPE)
|
||||
|
||||
lines.append(
|
||||
f"<{self._as_turtle_iri(source_id)}> "
|
||||
f"<{self._as_turtle_iri(rel_type)}> "
|
||||
f"<{self._as_turtle_iri(target_id)}> ."
|
||||
f"<{self._as_turtle_iri(source_id, merged_namespaces)}> "
|
||||
f"<{self._as_turtle_iri(rel_type, merged_namespaces)}> "
|
||||
f"<{self._as_turtle_iri(target_id, merged_namespaces)}> ."
|
||||
)
|
||||
|
||||
if include_temporal:
|
||||
|
||||
@@ -56,3 +56,22 @@ def test_turtle_preserves_absolute_iris():
|
||||
RDF.type,
|
||||
URIRef("urn:example:Person"),
|
||||
) in parsed
|
||||
|
||||
|
||||
def test_turtle_expands_context_prefixes_and_normalizes_malformed_iris():
|
||||
"""Prefixes expand and malformed URI-like values are minted."""
|
||||
turtle = RDFExporter().export_to_rdf(
|
||||
{
|
||||
"@context": {"ex": "https://example.org/"},
|
||||
"entities": [{"id": "http://[invalid", "type": "ex:Person"}],
|
||||
"relationships": [],
|
||||
},
|
||||
format="turtle",
|
||||
)
|
||||
parsed = Graph().parse(data=turtle, format="turtle")
|
||||
|
||||
assert (
|
||||
URIRef("https://semantica.dev/ns#http%3A%2F%2F%5Binvalid"),
|
||||
RDF.type,
|
||||
URIRef("https://example.org/Person"),
|
||||
) in parsed
|
||||
|
||||
Reference in New Issue
Block a user