The `prefixmaps` library, currently at version 0.2.6, is a Python tool for managing and resolving semantic prefix maps, particularly for CURIEs (Compact URIs). It simplifies the expansion of short-form identifiers into full IRIs and vice versa, primarily by leveraging community-maintained prefix registries like those from OBO Foundry. Releases occur periodically to update prefix data and improve functionality.
pip install prefixmapsVerified import paths — ran on the pinned version, not inferred.
Demonstrates initializing a PrefixMap, expanding a CURIE, compressing an IRI, and checking for prefix existence.
Use `pm = PrefixMap()` for the default registry or `PrefixMap.load_default_registry()` for explicit loading.
For offline or controlled environments, consider using `PrefixMap.load_from_json(filepath)` or `PrefixMap.load_from_shacl(filepath)` with a locally cached registry file. The library also allows specifying a custom URL for the registry.
Always check the return value of `pm.expand(curie)`: `iri = pm.expand(curie); if iri is None: print(f"Unknown prefix for {curie}")`.Use `pm = PrefixMap()` to load the default registry or `PrefixMap.load_default_registry()` if you need to load it explicitly without creating a new `PrefixMap` instance immediately.