📜  javascript 查找相似字符串 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:04.208000             🧑  作者: Mango

代码示例1
function similarity(s1, s2) {
  var longer = s1;
  var shorter = s2;
  if (s1.length < s2.length) {
    longer = s2;
    shorter = s1;
  }
  var longerLength = longer.length;
  if (longerLength == 0) {
    return 1.0;
  }
  return (longerLength - editDistance(longer, shorter)) / parseFloat(longerLength);
}