예제 #1
0
        if seq1[i] < seq2[i]:
            return -1
        elif seq1[i] > seq2[i]:
            return 1
        i += 1

    if len(seq1) < len(seq2):
        return -1
    elif len(seq1) > len(seq2):
        return 1

    return 0


# key for sorting strings alphabetically with numbers
number_aware_alphabetical_key = cmp_to_key(number_aware_alphabetical_cmp)


def match(wrong, candidates):
    """
    Returns a guess of which candidate is the right one
    based on the wrong word.

    Parameters
    ----------
    wrong : str
        A mispelling
    candidates : list of str
        A set of correct words

    Returns
예제 #2
0
        if seq1[i] < seq2[i]:
            return -1
        elif seq1[i] > seq2[i]:
            return 1
        i += 1

    if len(seq1) < len(seq2):
        return -1
    elif len(seq1) > len(seq2):
        return 1

    return 0


# key for sorting strings alphabetically with numbers
number_aware_alphabetical_key = cmp_to_key(number_aware_alphabetical_cmp)


def match(wrong, candidates):
    """
    Returns a guess of which candidate is the right one
    based on the wrong word.

    Parameters
    ----------
    wrong : str
        A mispelling
    candidates : list of str
        A set of correct words

    Returns