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:preferredNamespacePrefixannotation on the SKOS concept schemeuri_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:preferredNamespaceUriannotation on the SKOS concept schemereference_cls – The reference type to use
- Returns:
A list of literal mappings
This function will look for
rdfs:label,skos:prefLabel, andskos:altLabel. It will automatically assign a canonical label prioritizingrdfs:labeloverskos:prefLabeland 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:ConceptSchemein the graphExample usage:
import ssslm url = "https://raw.githubusercontent.com/dini-ag-kim/schulfaecher/refs/heads/main/schulfaecher.ttl" literal_mappings = ssslm.read_skos(url)