Labels¶
kurra.labels ¶
Functions to find RDF elements missing labels, and to acquire them from KurrawongAI's Semantic Background or another provided context.
find_missing_labels ¶
find_missing_labels(p: Path | str | Graph, local_context: Path | Graph | None = None) -> Iterable[URIRef]
Find all the IRIs in a graph missing labels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
p
|
Path | str | Graph
|
The RDF source to scan for IRIs missing labels as a file path, directory, RDF string, or Graph. |
required |
local_context
|
Path | Graph | None
|
An RDF file, directory, or Graph containing labels to check against, in addition to |
None
|
Returns:
| Type | Description |
|---|---|
Iterable[URIRef]
|
The IRIs missing a label. |
Source code in kurra/labels.py
get_labels ¶
get_labels(iris: list[URIRef], context: Graph | str | Path = 'https://fuseki.dev.kurrawong.ai/semback/sparql', return_type: Literal['graph', 'dict'] = 'graph', http_client: Client | None = None) -> Graph | dict[URIRef, str]
Get labels for the given IRIs from a given context, by default the KurrawongAI Semantic Background.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
iris
|
list[URIRef]
|
The IRIs to fetch labels for. |
required |
context
|
Graph | str | Path
|
An RDF Graph, file, directory, or SPARQL endpoint containing labels to check against. Defaults to the KurrawongAI Semantic Background. |
'https://fuseki.dev.kurrawong.ai/semback/sparql'
|
return_type
|
Literal['graph', 'dict']
|
|
'graph'
|
http_client
|
Client | None
|
An optional HTTPX client to contain credentials if needed to access a SPARQL endpoint as context. A new one is created if not given. |
None
|
Returns:
| Type | Description |
|---|---|
Graph | dict[URIRef, str]
|
A Graph if |
Source code in kurra/labels.py
jsonld_context ¶
Create a JSON-LD context mapping resource labels to their IRIs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
Graph
|
The graph to generate a context for. |
required |
vocabulary
|
Graph | None
|
An additional graph to source labels and class/property types from. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
A dict mapping each generated JSON-LD term to its IRI. |