#NEWLINE# @ staticmethod #NEWLINE# def sim_distance( p1 , p2 ) : #NEWLINE# #INDENT# 'Returns a distance-based similarity score for p1 and p2' #NEWLINE# si = [ item for item in p1 if ( item in p2 ) ] #NEWLINE# if ( len ( si ) != 0 ) : #NEWLINE# #INDENT# squares = [ pow ( ( p1 [ item ] - p2 [ item ] ) , 2 ) for item in si ] #NEWLINE# sum_of_squares = sum ( squares ) #NEWLINE# return ( 1 / ( 1 + sqrt ( sum_of_squares ) ) ) #NEWLINE# #UNINDENT# return 0