def _compression_dist(x, y, l_x=None, l_y=None):
if x == y:
return 0
x_b = x.encode('utf-8')
y_b = y.encode('utf-8')
if l_x is None:
l_x = len(lzma.compress(x_b))
l_y = len(lzma.compress(y_b))
l_xy = len(lzma.compress(x_b+y_b))
l_yx = len(lzma.compress(y_b+x_b))
dist = np_utils._try_divide(min(l_xy,l_yx)-min(l_x,l_y), max(l_x,l_y))
return dist
评论列表
文章目录