1

How is the ratio computed from the distance?

# https://pypi.python.org/pypi/python-Levenshtein/
>>> Levenshtein.distance('bjork gudmundsdottir', 'b. gudmundsson gunnar')
12
>>> len('bjork gudmundsdottir') + len('b. gudmundsson gunnar')
41
>>> Levenshtein.ratio('bjork gudmundsdottir', 'b. gudmundsson gunnar')
0.5853658536585366

I thought it was (dist-len)/len, but that seems incorrect. How is the above value of 0.58 arrived at?

Here is the closest I can get:

>>> Ldist / max(len( a ), len( b ))
>>> float(12)/21
0.5714285714285714

But still, this is off by .01. What would be the exact formula here?

David542
  • 104,438
  • 178
  • 489
  • 842

0 Answers0