(
    seq1: Sequence[str],
    seq2: Sequence[str],
    sim_func: Callable[[str, str], float] = edits.levenshtein,
)
return ((sum_maxsim1 / len(seq1)) + (sum_maxsim2 / len(seq2))) / 2
Measure the similarity between two sequences of strings using the (symmetric)
    Monge-Elkan method, which takes the average of the maximum pairwise similarity
    between the tokens in each sequence as compared to those in the other sequence.

    Args:
        seq1
        seq2
        sim_func: Callable that computes a string-to-string similarity metric;
            by default, Levenshtein edit distance.

    Returns:
        Similarity between ``seq1`` and ``seq2`` in the interval [0.0, 1.0],
        where larger values correspond to more similar strings.

    See Also:
        :func:`textacy.similarity.edits.levenshtein()`
Measure the similarity between two sequences of strings using the (symmetric)
    Monge-Elkan method, which takes the average of the maximum pairwise similarity
    between the tokens in each sequence as compared to those in the other sequence.
Measure the similarity between two sequences of strings using the ( symmetric ) Monge - Elkan method which takes the average of the maximum pairwise similarity between the tokens in each sequence as compared to those in the other sequence .
def monge_elkan(
    seq1: Sequence[str],
    seq2: Sequence[str],
    sim_func: Callable[[str, str], float] = edits.levenshtein,
) -> float:
    """
    Measure the similarity between two sequences of strings using the (symmetric)
    Monge-Elkan method, which takes the average of the maximum pairwise similarity
    between the tokens in each sequence as compared to those in the other sequence.

    Args:
        seq1
        seq2
        sim_func: Callable that computes a string-to-string similarity metric;
            by default, Levenshtein edit distance.

    Returns:
        Similarity between ``seq1`` and ``seq2`` in the interval [0.0, 1.0],
        where larger values correspond to more similar strings.

    See Also:
        :func:`textacy.similarity.edits.levenshtein()`
    """
    if not seq1 or not seq2:
        return 0.0

    sum_maxsim1 = sum(
        max(sim_func(tok1, tok2) for tok2 in seq2)
        for tok1 in seq1
    )
    sum_maxsim2 = sum(
        max(sim_func(tok2, tok1) for tok1 in seq1)
        for tok2 in seq2
    )
    return ((sum_maxsim1 / len(seq1)) + (sum_maxsim2 / len(seq2))) / 2
def monge_elkan ( seq1 : Sequence [ str ] , seq2 : Sequence [ str ] , sim_func : Callable [ [ str , str ] , float ] = edits . levenshtein , ) -> float : if not seq1 or not seq2 : return 0.0 sum_maxsim1 = sum ( max ( sim_func ( tok1 , tok2 ) for tok2 in seq2 ) for tok1 in seq1 ) sum_maxsim2 = sum ( max ( sim_func ( tok2 , tok1 ) for tok1 in seq1 ) for tok2 in seq2 ) return ( ( sum_maxsim1 / len ( seq1 ) ) + ( sum_maxsim2 / len ( seq2 ) ) ) / 2