from typing import List


def jaccard_similarity(correct_duplicates: List, retrieved_duplicates: List) -> float:
    """
    Get jaccard similarity for a single query given correct and retrieved file names.

    Args:
        correct_duplicates: List of correct duplicates i.e., ground truth)
        retrieved_duplicates: List of retrieved duplicates for one single query

    Returns:
        Jaccard similarity for this query.
    """
    if len(retrieved_duplicates) == 0 and len(correct_duplicates) == 0:
        return 1.0

    if not len(retrieved_duplicates) or not len(correct_duplicates):
        return 0.0

    set_correct_duplicates = set(correct_duplicates)
    set_retrieved_duplicates = set(retrieved_duplicates)

    intersection_dups = set_retrieved_duplicates.intersection(set_correct_duplicates)
    union_dups = set_retrieved_duplicates.union(set_correct_duplicates)

    jacc_sim = len(intersection_dups) / len(union_dups)
    return jacc_sim