src/compute_cossim.py
def edit_distance(list1, list2):
    '''
    args:
      list1: a list with string elements 
      list2: a list with string elements
        list1 and list2 should have the same type
        
    return:
      compute_mat[-1][-1]: the edit distance of two
        different list

    '''
    compute_mat = [[0 for i in range(len(list1)+1) ]
        for j in range(len(list2)+1)]
    for i in range(len(list1)+1):
        compute_mat[0][i] = i
    for i in range(len(list2)+1):
        compute_mat[i][0] = i
    for i in range(1,len(list2)+1):
        for j in range(1,len(list1)+1):
            if list1[j-1] == list2[i-1] :
                compute_mat[i][j] = compute_mat[i-1][j-1]
            else:
                compute_mat[i][j] = min( 
                    1+ compute_mat[i-1][j],    # insertion
                    1 + compute_mat[i][j-1],   # deletion
                    1 + compute_mat[i-1][j-1]) # substitution

    return compute_mat[-1][-1]

    args:
      list1: a list with string elements 
      list2: a list with string elements
        list1 and list2 should have the same type
        
    return:
      compute_mat[-1][-1]: the edit distance of two
        different list

    
a list with string elements
list2: a list with string elements
list1 and list2 should have the same type

compute_mat[-1][-1]: the edit distance of two
different list
a list with string elements list2 : a list with string elements list1 and list2 should have the same type compute_mat [ - 1 ] [ - 1 ] : the edit distance of two different list
def edit_distance(list1, list2):
    compute_mat = [[0 for i in range(len(list1)+1) ]
        for j in range(len(list2)+1)]
    for i in range(len(list1)+1):
        compute_mat[0][i] = i
    for i in range(len(list2)+1):
        compute_mat[i][0] = i
    for i in range(1,len(list2)+1):
        for j in range(1,len(list1)+1):
            if list1[j-1] == list2[i-1] :
                compute_mat[i][j] = compute_mat[i-1][j-1]
            else:
                compute_mat[i][j] = min( 
                    1+ compute_mat[i-1][j],    
                    1 + compute_mat[i][j-1],   
                    1 + compute_mat[i-1][j-1]) 
    return compute_mat[-1][-1]
def edit_distance ( list1 , list2 ) : compute_mat = [ [ 0 for i in range ( len ( list1 ) + 1 ) ] for j in range ( len ( list2 ) + 1 ) ] for i in range ( len ( list1 ) + 1 ) : compute_mat [ 0 ] [ i ] = i for i in range ( len ( list2 ) + 1 ) : compute_mat [ i ] [ 0 ] = i for i in range ( 1 , len ( list2 ) + 1 ) : for j in range ( 1 , len ( list1 ) + 1 ) : if list1 [ j - 1 ] == list2 [ i - 1 ] : compute_mat [ i ] [ j ] = compute_mat [ i - 1 ] [ j - 1 ] else : compute_mat [ i ] [ j ] = min ( 1 + compute_mat [ i - 1 ] [ j ] , 1 + compute_mat [ i ] [ j - 1 ] , 1 + compute_mat [ i - 1 ] [ j - 1 ] ) return compute_mat [ - 1 ] [ - 1 ]
args:
list1: a list with string elements
list2: a list with string elements
list1 and list2 should have the same type
args : list1 : a list with string elements list2 : a list with string elements list1 and list2 should have the same type
'''
    args:
      list1: a list with string elements 
      list2: a list with string elements
        list1 and list2 should have the same type
        
    return:
      compute_mat[-1][-1]: the edit distance of two
        different list

    ''' # insertion # deletion # substitution
list1
list2