hermes.model.types.ld_context
=============================

.. py:module:: hermes.model.types.ld_context


Attributes
----------

.. autoapisummary::

   hermes.model.types.ld_context.CODEMETA_PREFIX
   hermes.model.types.ld_context.CODEMETA_CONTEXT
   hermes.model.types.ld_context.SCHEMA_ORG_PREFIX
   hermes.model.types.ld_context.SCHEMA_ORG_CONTEXT
   hermes.model.types.ld_context.PROV_PREFIX
   hermes.model.types.ld_context.PROV_CONTEXT
   hermes.model.types.ld_context.HERMES_RT_PREFIX
   hermes.model.types.ld_context.HERMES_RT_CONTEXT
   hermes.model.types.ld_context.HERMES_CONTENT_CONTEXT
   hermes.model.types.ld_context.HERMES_CONTEXT
   hermes.model.types.ld_context.HERMES_BASE_CONTEXT
   hermes.model.types.ld_context.HERMES_PROV_CONTEXT
   hermes.model.types.ld_context.ALL_CONTEXTS
   hermes.model.types.ld_context.iri_map


Classes
-------

.. autoapisummary::

   hermes.model.types.ld_context.ContextPrefix


Module Contents
---------------

.. py:data:: CODEMETA_PREFIX
   :type:  str
   :value: 'https://doi.org/10.5063/schema/codemeta-2.0'


   The prefix for codemeta terms.

.. py:data:: CODEMETA_CONTEXT
   :type:  list[str]

   The prefix for codemeta terms wrapped inside a list.

.. py:data:: SCHEMA_ORG_PREFIX
   :type:  str
   :value: 'http://schema.org/'


   The prefix for schema.org terms.

.. py:data:: SCHEMA_ORG_CONTEXT
   :type:  list[dict[str, str]]

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

.. py:data:: PROV_PREFIX
   :type:  str
   :value: 'http://www.w3.org/ns/prov#'


   The prefix for provenance terms.

.. py:data:: PROV_CONTEXT
   :type:  list[dict[str, str]]

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

.. py:data:: HERMES_RT_PREFIX
   :type:  str
   :value: 'https://schema.software-metadata.pub/hermes-runtime/1.0/'


   The prefix for HERMES runtime terms.

.. py:data:: HERMES_RT_CONTEXT
   :type:  list[dict[str, str]]

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

.. py:data:: HERMES_CONTENT_CONTEXT
   :type:  list[dict[str, str]]

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

.. py:data:: HERMES_CONTEXT
   :type:  list[dict[str, str]]

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

.. py:data:: HERMES_BASE_CONTEXT
   :type:  list[dict[str, str]]

   The JSON_LD context commonly used by HERMES excluding provenance context.

.. py:data:: HERMES_PROV_CONTEXT
   :type:  list[dict[str, str]]

   The JSON_LD context commonly used by HERMES excluding codemeta context.

.. py:data:: ALL_CONTEXTS
   :type:  list[Union[str, dict[str, str]]]

   The JSON_LD context commonly used by HERMES.

   :type: list[str | dict[str, str]]

.. py:class:: ContextPrefix(vocabularies: list[Union[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.

   .. attribute:: vocabularies

      The list of JSON_LD context used for expansion.

      :type: list[str | dict]

   .. attribute:: context dict[str | None, str]

      The mapping of prefix its expanded IRI.


   .. py:method:: __getitem__(compressed_term: Union[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"]

      :param compressed_term: 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.
      :type compressed_term: str | tuple

      :returns: The fully qualified IRI for the passed term
      :rtype: str

      :raises HermesCacheError: If the compressed term is '' or its prefix can't be expanded.



.. py:data:: iri_map
   :type:  ContextPrefix

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

