def filter_connections(connections, annotations):
    """
    Keep connections if they were assigned the 'Equal' label
    or if they were not annotated.

    :param list connections: List of candidate connections.
    :param list annotations: List of annotations from the
                             prodigy db-out command.
    :returns: Filtered connections.
    :rtype: list
    """
    # 1 corresponds to the equal label.
    annotated_idxs = [ann["_input_hash"] for ann in annotations]
    not_annotated_idxs = [i for i in range(len(connections))
                          if i not in annotated_idxs]
    equal_idxs = [ann["_input_hash"] for ann in annotations
                  if ann["answer"] == "accept" and 1 in ann["accept"]]
    keep_idxs = equal_idxs + not_annotated_idxs
    cnxs = [connections[i] for i in keep_idxs]
    return cnxs