read_skos

read_skos(graph: str | rdflib.Graph, curie_prefix: str | None = None, uri_prefix: str | None = None, reference_cls: type[R] = None) list[LiteralMapping][source]
read_skos(graph: str | rdflib.Graph, curie_prefix: str | None = None, uri_prefix: str | None = None, reference_cls: None = None) list[LiteralMapping[NamedReference]]

Read literal mappings from a SKOS.

Parameters:
  • graph – Either a URL to a SKOS concept scheme or a pre-parsed SKOS concept scheme in a rdflib.Graph.

  • curie_prefix – The CURIE prefix used to parse the SKOS graph. If not given, will try to infer by querying the vocabulary for a vann:preferredNamespacePrefix annotation on the SKOS concept scheme

  • uri_prefix – The URI prefix used to identify terms from the SKOS vocabulary. If not given, will try to infer by querying the vocabulary for a vann:preferredNamespaceUri annotation on the SKOS concept scheme

  • reference_cls – The reference type to use

Returns:

A list of literal mappings

This function will look for rdfs:label, skos:prefLabel, and skos:altLabel. It will automatically assign a canonical label prioritizing rdfs:label over skos:prefLabel and English over other languages. It maintains the predicates in the literal mappings and does not attempt to map to OBO in OWL predicates.

Warning

This function assumes there is only one skos:ConceptScheme in the graph

Example usage:

import ssslm

url = "https://raw.githubusercontent.com/dini-ag-kim/schulfaecher/refs/heads/main/schulfaecher.ttl"
literal_mappings = ssslm.read_skos(url)