def check_r_s_same_size(R, S):
    """
    Raises an exception if R and S have different number of distinct elements

    Args:
        R (list of list): the gold standard
        S (list of list): the partition, output of the entity resolution that we want to evaluate
    """
    R_set = set()
    S_set = set()
    for i, val in enumerate(R):
        for j, rec in enumerate(val):
            R_set.add(rec)
    for i, val in enumerate(S):
        for j, rec in enumerate(val):
            S_set.add(rec)
    if len(R_set) != len(S_set):
        raise ValueError(
            'R and S have different numbers of distincts records : R has',
            len(R_set), 'distinct records while S has', len(S_set),
            'distinct records')
