def _token_to_dep_tuple(token, id_map):
    """
    Creates a tuple of primitives to represent the dependency on a token.

    Args:
        token: The token to convert to a tupled dependency representation.
        id_map: A mapping from string token ids to indices.

    Returns:
        A triplet where the first element is the minimum of the token id and
        governor id, the second is the maximum, and the third is the direction
        of the dependency.
    """
    token_idx = id_map[token.id]
    head_idx = id_map[token.head]
    if token_idx < head_idx:
        return token_idx, head_idx, 'r'
    return head_idx, token_idx, 'l'
