Skip to content

Functions:

  • load_list_re

    Recursively iterate over RDF list containers for extracting lists of lists.

load_list_re

load_list_re(graph, first_node, parse_uri=True, quiet=True)

Recursively iterate over RDF list containers for extracting lists of lists.

Parameters:

  • graph (Graph) –

    Graph object to extract the list(s) from

  • first_node (BNode) –

    First element in the list

  • parse_uri (bool, default: True ) –

    if True will try converting literals into URIRef

  • quiet (bool, default: True ) –

    if True will not throw exceptions other than loop detection

Raises:

  • RuntimeError

    When a loop is detected

  • ValueError

    When quiet is False and short URI cannot be expanded

Source code in src/rdf_utils/collection.py
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
def load_list_re(
    graph: Graph, first_node: BNode, parse_uri: bool = True, quiet: bool = True
) -> list[Any]:
    """Recursively iterate over RDF list containers for extracting lists of lists.

    Parameters:
        graph: Graph object to extract the list(s) from
        first_node: First element in the list
        parse_uri: if True will try converting literals into URIRef
        quiet: if True will not throw exceptions other than loop detection

    Raises:
        RuntimeError: When a loop is detected
        ValueError: When `quiet` is `False` and short URI cannot be expanded
    """
    node_set = set()

    return _load_list_re(graph, first_node, node_set, parse_uri, quiet)