擅长:python、mysql、java
<p>虽然没有绝对的标准,但是规范化的levensinide距离是最常用的定义。这两个例子都是0.5。</p>
<p>由于<code>max</code>是Levenshtein距离的最低上限,因此它是有意义的:要从<code>b</code>中获得<code>a</code>,在<code>len(a) > len(b)</code>中,您始终可以用<code>a</code>中的相应元素替换<code>len(b)</code>中的第一个<code>b</code>元素,然后插入缺少的部分<code>a[len(b):]</code>,总共进行<code>len(a)</code>编辑操作。</p>
<p>这个参数显然扩展到了<code>len(a) <= len(b)</code>的情况。要将规范化距离转换为相似性度量,请将其从1中减去:<code>1 - ldist / max(len(a), len(b))</code>。</p>