import re


def get_instances_from_report(report_file_path):
    """
    Parse StegExpose report and return a list of (class, score).
    E.g. [('p', 0.10), ('n', 0.05)]
    """

    instances = []
    with open(report_file_path, 'r') as report_file:
        for line in report_file:
            # Filter the lines without images.
            if re.match(r'.*\.(png|jpg),', line):
                # Get the important data.
                pieces = line.split(sep=',')
                image_name = pieces[0]
                real_class = 'p' if re.match(r'.*_\d+p\.(png|jpg),', line) else 'n'
                fusion_score = float(pieces[-1])
                # print(real_class, fusion_score, image_name)
                instances.append((real_class, fusion_score))
    return instances