Skip to content

models

Functions:

convert_vocab_map_to_list

convert_vocab_map_to_list(
    vocab_map: dict | None,
) -> list[dict]

Convert map generated in the SQL query to a list of vocab dictionary objects.

See the SQL query in the sql/ directory. The relevant selection is: map(list(trm_Label), list( { "description": trm_Description, "url": trm_SemanticReferenceURL, "id": trm_ID }) ) AS terms

Examples:

>>> vocab0 = {'perg': {'description': 'Parchment', 'url': None, 'id': 9782}}
>>> vocab1 = {'chart': {'description': 'Paper', 'url': None, 'id': 9783}}
>>> vocab2 = {'mixed': {'description': None, 'url': None, 'id': 9785}}
>>> map = vocab0 | vocab1 | vocab2
>>> terms = convert_vocab_map_to_list(map)
>>> len(terms)
3
>>> terms[0]
{'label': 'perg', 'description': 'Parchment', 'url': None, 'id': 9782}

Parameters:

  • vocab_map

    (dict | None) –

    Map created in SQL query from aggregation function.

Returns:

  • list[dict]

    list[dict]: List of vocabulary term metadata in dictionary objects.