1function similarity(s1, s2) {
2 var longer = s1;
3 var shorter = s2;
4 if (s1.length < s2.length) {
5 longer = s2;
6 shorter = s1;
7 }
8 var longerLength = longer.length;
9 if (longerLength == 0) {
10 return 1.0;
11 }
12 return (longerLength - editDistance(longer, shorter)) / parseFloat(longerLength);
13}