def relation_completions(<EOL>completion_text: str, bel_spec: BELSpec, bel_fmt: str, size: int<EOL>) -> list:
if bel_fmt == "<STR_LIT>":<EOL><INDENT>relation_list = bel_spec["<STR_LIT>"]["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>relation_list = bel_spec["<STR_LIT>"]["<STR_LIT>"]<EOL><DEDENT>matches = []<EOL>for r in relation_list:<EOL><INDENT>if re.match(completion_text, r):<EOL><INDENT>matches.append(r)<EOL><DEDENT><DEDENT>replace_list = []<EOL>for match in matches:<EOL><INDENT>highlight = match.replace(completion_text, f"<STR_LIT>")<EOL>replace_list.append(<EOL>{<EOL>"<STR_LIT>": match,<EOL>"<STR_LIT:label>": match,<EOL>"<STR_LIT>": highlight,<EOL>"<STR_LIT:type>": "<STR_LIT>",<EOL>}<EOL>)<EOL><DEDENT>return replace_list[:size]<EOL>
Filter BEL relations by prefix

    Args:
        prefix: completion string
        bel_fmt: short, medium, long BEL formats
        spec: BEL specification

    Returns:
        list: list of BEL relations that match prefix