cmem_client.components.explore.titles¤
Titles of resources, resolved by the Corporate Memory Explore title service.
Classes:
- ExploreTitles – Resolve IRIs to human-readable titles, with one request per batch and a cache.
ExploreTitles¤
Resolve IRIs to human-readable titles, with one request per batch and a cache.
Explore resolves a title from the label of a resource, in the language it prefers, and derives one from the IRI when there is no label. Every answer is cached per IRI and context graph for as long as the client lives, so a title is requested only once. There is no endpoint listing all titles, so this is a feature of the Explore component rather than a repository.
Examples:
>>> from cmem_client.client import Client
>>> client = Client.from_env()
>>> titles = client.explore.titles.get_many(["https://vocab.eccenca.com/shacl/", "urn:x:a"])
>>> client.explore.titles.get("https://vocab.eccenca.com/shacl/").title
Functions:
- get – Get the title of one IRI.
- get_many – Get the titles of several IRIs, with one request for all which are not cached yet.
Parameters:
- client (
Client) – A configured Corporate Memory client instance.
get¤
Get the title of one IRI.
Parameters:
- iri (
str) – The IRI to resolve. - context_graph (
str | None) – The graph to read the label from, if not all graphs. - refresh (
bool) – Ask the service again instead of using a cached title.
Returns:
Title– The title of the IRI. An IRI the service does not answer for gets itself as title.
Raises:
HTTPStatusError– If the title service rejects the request.
get_many¤
Get the titles of several IRIs, with one request for all which are not cached yet.
Parameters:
- iris (
Iterable[str]) – The IRIs to resolve. Duplicates are resolved once. - context_graph (
str | None) – The graph to read the labels from, if not all graphs. - refresh (
bool) – Ask the service again for all of them instead of using cached titles.
Returns:
dict[str, Title]– The title of every IRI, by IRI and in the order given. An IRI the service doesdict[str, Title]– not answer for gets itself as title, and is asked for again next time.
Raises:
HTTPStatusError– If the title service rejects the request.