# src/extractor/canon/clusterer.py

AUTO_MERGE_THRESHOLD = 92  # token_set_ratio >= 92 → auto merge
REVIEW_THRESHOLD = 78  # 78-91 → flag for review
# < 78 → different entities


def similarity_score(a: str, b: str) -> float:
    try:
        from rapidfuzz import fuzz  # type: ignore[import-untyped]

        return float(
            max(
                fuzz.token_set_ratio(a, b),
                fuzz.token_sort_ratio(a, b),
                fuzz.partial_ratio(a, b),
            )
        )
    except ImportError:
        return 0.0
