import logging


def check_dataset(df, comments):
    """
    The check_dataset method runs on a labeling_progress.pickle to make sure all indexes match
    :param df: master DataFrame
    :param comments: master comments.json file
    :return: an error flag (1) if the two records do not match; 0 otherwise
    """
    if len(df) != len(comments):
        return 1

    mismatched = []
    for i in range(len(df)):
        if df.iloc[i]['label'] != comments[i]['label']:
            mismatched.append(i)

    if len(mismatched) > 0:
        logging.error(f'Mismatched comments at positions: {mismatched}')
        return 1

    return 0