mtp/machamp/dataset_readers/lemma_edit.py
def min_edit_script(source, target, allow_copy=False):
    """
    Finds the minimum edit script to transform the source to the target
    """
    a = [[(len(source) + len(target) + 1, None)] * (len(target) + 1) for _ in range(len(source) + 1)]
    for i in range(0, len(source) + 1):
        for j in range(0, len(target) + 1):
            if i == 0 and j == 0:
                a[i][j] = (0, "")
            else:
                if allow_copy and i and j and source[i - 1] == target[j - 1] and a[i-1][j-1][0] < a[i][j][0]:
                    a[i][j] = (a[i-1][j-1][0], a[i-1][j-1][1] + "→")
                if i and a[i-1][j][0] < a[i][j][0]:
                    a[i][j] = (a[i-1][j][0] + 1, a[i-1][j][1] + "-")
                if j and a[i][j-1][0] < a[i][j][0]:
                    a[i][j] = (a[i][j-1][0] + 1, a[i][j-1][1] + "+" + target[j - 1])
    return a[-1][-1][1]

    Finds the minimum edit script to transform the source to the target
    
Finds the minimum edit script to transform the source to the target
Finds the minimum edit script to transform the source to the target
def min_edit_script(source, target, allow_copy=False):
    a = [[(len(source) + len(target) + 1, None)] * (len(target) + 1) for _ in range(len(source) + 1)]
    for i in range(0, len(source) + 1):
        for j in range(0, len(target) + 1):
            if i == 0 and j == 0:
                a[i][j] = (0, "")
            else:
                if allow_copy and i and j and source[i - 1] == target[j - 1] and a[i-1][j-1][0] < a[i][j][0]:
                    a[i][j] = (a[i-1][j-1][0], a[i-1][j-1][1] + "→")
                if i and a[i-1][j][0] < a[i][j][0]:
                    a[i][j] = (a[i-1][j][0] + 1, a[i-1][j][1] + "-")
                if j and a[i][j-1][0] < a[i][j][0]:
                    a[i][j] = (a[i][j-1][0] + 1, a[i][j-1][1] + "+" + target[j - 1])
    return a[-1][-1][1]
def min_edit_script ( source , target , allow_copy = False ) : a = [ [ ( len ( source ) + len ( target ) + 1 , None ) ] * ( len ( target ) + 1 ) for _ in range ( len ( source ) + 1 ) ] for i in range ( 0 , len ( source ) + 1 ) : for j in range ( 0 , len ( target ) + 1 ) : if i == 0 and j == 0 : a [ i ] [ j ] = ( 0 , "" ) else : if allow_copy and i and j and source [ i - 1 ] == target [ j - 1 ] and a [ i - 1 ] [ j - 1 ] [ 0 ] < a [ i ] [ j ] [ 0 ] : a [ i ] [ j ] = ( a [ i - 1 ] [ j - 1 ] [ 0 ] , a [ i - 1 ] [ j - 1 ] [ 1 ] + "→") if i and a [ i - 1 ] [ j ] [ 0 ] < a [ i ] [ j ] [ 0 ] : a [ i ] [ j ] = ( a [ i - 1 ] [ j ] [ 0 ] + 1 , a [ i - 1 ] [ j ] [ 1 ] + "-" ) if j and a [ i ] [ j - 1 ] [ 0 ] < a [ i ] [ j ] [ 0 ] : a [ i ] [ j ] = ( a [ i ] [ j - 1 ] [ 0 ] + 1 , a [ i ] [ j - 1 ] [ 1 ] + "+" + target [ j - 1 ] ) return a [ - 1 ] [ - 1 ] [ 1 ]
Finds the minimum edit script to transform the source to the target
Finds the minimum edit script to transform the source to the target
"""
    Finds the minimum edit script to transform the source to the target
    """
source
target
allow_copy