from typing import FrozenSet


def _vocabulary_overlap(vocabulary1: FrozenSet[str],
                        vocabulary2: FrozenSet[str]):
    """
    Vocabulary overlap as calculated by the Jaccard coefficient.
    """
    intersection_length = len(vocabulary1 & vocabulary2)
    if intersection_length == 0:
        return 0
    return (
            intersection_length /
            (len(vocabulary1) + len(vocabulary2) - intersection_length)
    )