[issue45180] possible wrong result for difflib.SequenceMatcher.ratio()

Nabeel Alzahrani report at bugs.python.org
Thu Sep 16 00:33:04 EDT 2021


Nabeel Alzahrani <nalza001 at ucr.edu> added the comment:

Here are the steps that I used to calculate 0.2 for the last example:

I used class difflib.HtmlDiff to find the number of changed chars (addedChars, deletedChars, and changedChars) which is 1172 (let us call it delta)

The size of both strings a and b in this example is 1470

I calculated the similality ratio using 1-(delta/totalSize) = 1-(1172/1470)=0.2

I am assuming both classes difflib.SequenceMatcher and difflib.HtmlDiff are both using the same algorithms and arguments and if so they should produce the same ratio. Is that right?

----------
status: closed -> open

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45180>
_______________________________________


More information about the Python-bugs-list mailing list