hermes.model.types.ld_context

Attributes

CODEMETA_PREFIX

The prefix for codemeta terms.

CODEMETA_CONTEXT

The prefix for codemeta terms wrapped inside a list.

SCHEMA_ORG_PREFIX

The prefix for schema.org terms.

SCHEMA_ORG_CONTEXT

The prefix for schema.org terms as value of the shortend prefix schema in a dict inside of a list.

PROV_PREFIX

The prefix for provenance terms.

PROV_CONTEXT

The prefix for provenance terms as value of the shortend prefix schema in a dict inside of a list.

HERMES_RT_PREFIX

The prefix for HERMES runtime terms.

HERMES_RT_CONTEXT

The prefix for HERMES runtime terms as value of the shortend prefix schema in a dict inside of a list.

HERMES_CONTENT_CONTEXT

The prefix for HERMES content terms as value of the shortend prefix schema in a dict inside of a list.

HERMES_CONTEXT

A list containing a dict containing all key, value pairs from HERMES_RT_CONTEXT and HERMES_CONTENT_CONTEXT.

HERMES_BASE_CONTEXT

The JSON_LD context commonly used by HERMES excluding provenance context.

HERMES_PROV_CONTEXT

The JSON_LD context commonly used by HERMES excluding codemeta context.

ALL_CONTEXTS

The JSON_LD context commonly used by HERMES.

iri_map

An object returning the fully qualified IRI for a compressed term using the contexts in ALL_CONTEXTS.

Classes

ContextPrefix

FIXME: Rename to LDContext, HermesLDContext or similar, as this class represents JSON-LD contexts.

Module Contents

hermes.model.types.ld_context.CODEMETA_PREFIX: str = 'https://doi.org/10.5063/schema/codemeta-2.0'

The prefix for codemeta terms.

hermes.model.types.ld_context.CODEMETA_CONTEXT: list[str]

The prefix for codemeta terms wrapped inside a list.

hermes.model.types.ld_context.SCHEMA_ORG_PREFIX: str = 'http://schema.org/'

The prefix for schema.org terms.

hermes.model.types.ld_context.SCHEMA_ORG_CONTEXT: list[dict[str, str]]

The prefix for schema.org terms as value of the shortend prefix schema in a dict inside of a list.

hermes.model.types.ld_context.PROV_PREFIX: str = 'http://www.w3.org/ns/prov#'

The prefix for provenance terms.

hermes.model.types.ld_context.PROV_CONTEXT: list[dict[str, str]]

The prefix for provenance terms as value of the shortend prefix schema in a dict inside of a list.

hermes.model.types.ld_context.HERMES_RT_PREFIX: str = 'https://schema.software-metadata.pub/hermes-runtime/1.0/'

The prefix for HERMES runtime terms.

hermes.model.types.ld_context.HERMES_RT_CONTEXT: list[dict[str, str]]

The prefix for HERMES runtime terms as value of the shortend prefix schema in a dict inside of a list.

hermes.model.types.ld_context.HERMES_CONTENT_CONTEXT: list[dict[str, str]]

The prefix for HERMES content terms as value of the shortend prefix schema in a dict inside of a list.

hermes.model.types.ld_context.HERMES_CONTEXT: list[dict[str, str]]

A list containing a dict containing all key, value pairs from HERMES_RT_CONTEXT and HERMES_CONTENT_CONTEXT.

hermes.model.types.ld_context.HERMES_BASE_CONTEXT: list[dict[str, str]]

The JSON_LD context commonly used by HERMES excluding provenance context.

hermes.model.types.ld_context.HERMES_PROV_CONTEXT: list[dict[str, str]]

The JSON_LD context commonly used by HERMES excluding codemeta context.

hermes.model.types.ld_context.ALL_CONTEXTS: list[str | dict[str, str]]

The JSON_LD context commonly used by HERMES.

Type:

list[str | dict[str, str]]

class hermes.model.types.ld_context.ContextPrefix(vocabularies: list[str | dict])

FIXME: Rename to LDContext, HermesLDContext or similar, as this class represents JSON-LD contexts. Represents the context of the hermes JSON-LD data model and provides two views on the model:

  • as a list of linked data vocabularies, where items can be vocabulary base IRI strings and/or dictionaries mapping

    arbitrary strings used to prefix terms from a specific vocabulary to their respective vocabulary IRI strings.;

  • as a dict mapping prefixes to vocabulary IRIs, where the default vocabulary has a prefix of None.

vocabularies

The list of JSON_LD context used for expansion.

Type:

list[str | dict]

context dict[str | None, str]

The mapping of prefix its expanded IRI.

__getitem__(compressed_term: str | tuple) → str

Gets the fully qualified IRI for a term from a vocabulary inside the initialized context. The vocabulary must have been added to the context at initialization.

Example uses:

context = <self>([“iri_default”, {“prefix1”: “iri1”}])

# access qualified term via str

term = context[“term_in_default_vocabulary”]

term = context[“prefix1:term”]

# access qualified term via tuple

term = context[“prefix1”, “term”]

term = context[None, “term_in_default_vocabulary”]

Parameters:

compressed_term (str | tuple) – A term from a vocabulary in the context; terms from the default vocabulary are passed with a prefix of None, or as an unprefixed string, terms from non-default vocabularies are prefixed with the defined prefix for the vocabulary. The term can either be passed in as string <term> if prefix is None, or “<prefix>:<term>”, or as a tuple.

Returns:

The fully qualified IRI for the passed term

Return type:

str

Raises:

HermesCacheError – If the compressed term is ‘’ or its prefix can’t be expanded.

hermes.model.types.ld_context.iri_map: ContextPrefix

An object returning the fully qualified IRI for a compressed term using the contexts in ALL_CONTEXTS.