import logging


def compareFuzzies(known_fuzz, comparison_fuzz):
    """
    The compareFuzzies function compares Fuzzy Hashes
    :param known_fuzz: list of hashes from the known file
    :param comparison_fuzz: list of hashes from the comparison file
    :return: dictionary of formatted results for output
    """

    matches = known_fuzz.intersection(comparison_fuzz)

    if len(comparison_fuzz):
        similarity = (float(len(matches))/len(known_fuzz))*100
    else:
        logging.error('Comparison file not fuzzed. Please check file size and permissions')
        similarity = 0

    return {'similarity': similarity, 'matching_segments': len(matches),
        'known_file_total_segments': len(known_fuzz)}