String Comparisons returning score

Jay Parlar jparlar at home.com
Sun Sep 2 00:08:02 EDT 2001


I do believe that the difflib library is what you desire, and more specifically, SequenceMatcher from said library. If I 
remember correctly, it's described quite well in the documentation. Hope this helps!

> Is there an approved standard library/function/algarithm for comparing
> two similar strings and returning a percentage match?
> 
> I am aware of soundEx.py / .c  which is based on the grammar and
> phonetics of words, but from what I have read it seems to be flawed..
> and thus removed from the python standard library.
> 
> I have noticed similar techniques in other languages which are based
> on shift matrixes, working out the minimum number of changes to
> transform string A into string B.
> 
> I am more looking for one which looks at 
> words/
> chars/
> char-order/
> length/
> similarity
> perhaps omitting spaces, and a common library (the,a,and,mr,mrs......)
> with a weighted scoring mechanism...
> 
> Thanks in advance...
> Clayton Brown / Emmie Osawa


Jay Parlar
----------------------------------------------------------------
Software Engineering III
McMaster University
Hamilton, Ontario, Canada

"Though there are many paths
At the foot of the mountain
All those who reach the top
See the same moon."





More information about the Python-list mailing list