Utilities for constructing and working with IRIs and related concepts in executable knowledge graphs.
These helpers are used throughout ekglib to keep knowledge graph identifiers consistent and well-structured.
kgiri_random() -> URIRef - Generate a random KGIRI using a UUIDkgiri_with(key: str) -> URIRef - Create a KGIRI from a given key stringparse_identity_key(legacy_id: Any) -> str - Parse a legacy identifier into a normalized keyparse_identity_key_with_prefix(prefix: str, legacy_id: Any) -> str - Parse an identifier with a prefixset_ekg_namespace(key: str, iri: str) -> None - Set an EKG namespace mappingset_ekg_namespace_with_base(key: str, base: str, suffix: str) -> None - Set namespace with base and suffixset_kgiri_base(ekg_kgiri_base: Optional[str]) -> None - Set the base IRI for KGIRI generationset_kgiri_base_replace(ekg_kgiri_base_replace: Optional[str]) -> None - Set replacement base for KGIRIcomplete_ns_iri_ending(iri) - Complete a namespace IRI endingkgiri_replace(value: Any) -> Any - Replace IRIs in a value using the configured basekgiri_replace_iri_in_graph(g: Graph) -> None - Replace IRIs throughout an RDF graphkgiri_replace_iri_in_literal(value: Literal) -> Literal - Replace IRIs in an RDF literalset_cli_params(parser: argparse.ArgumentParser) -> Any - Add KGIRI-related CLI arguments (--kgiri-base, --kgiri-base-replace)from ekglib.kgiri import kgiri_with, kgiri_random, set_kgiri_base
# Set the base IRI (typically via environment variable EKG_KGIRI_BASE)
set_kgiri_base("https://kg.your-company.kom/")
# Generate IRIs
iri1 = kgiri_with("person/12345")
iri2 = kgiri_random() # Uses UUID