B
Bruce Eckel
Ah, but here's an interesting one:
So if it matches half the string it's 50% but if the last two
characters are out of order that's an additional 25%.
Other examples:
1.0
You get a different interpretation for each "speed" of ratio.
I started thinking that all I wanted was a pass-fail kind of thing so
I wondered if real_quick_ratio() might do the trick. But with the
following experiments:
1.0
It seems like there's no way to get real_quick_ratio() to say anything
except "it's a perfect match!" I'm wondering if someone didn't leave a
code stub unwritten:
def real_quick_ratio(self): return 1.0
Bruce Eckel http://www.BruceEckel.com mailto:[email protected]
Contains electronic books: "Thinking in Java 3e" & "Thinking in C++ 2e"
Web log: http://www.mindview.net/WebLog
Subscribe to my newsletter:
http://www.mindview.net/Newsletter
My schedule can be found at:
http://www.mindview.net/Calendar
"The whole problem with the world is that fools and fanatics are always
so certain of themselves, and wiser people so full of doubts."
--Bertrand Russell
0.50.75
So if it matches half the string it's 50% but if the last two
characters are out of order that's an additional 25%.
Other examples:
1.0
You get a different interpretation for each "speed" of ratio.
I started thinking that all I wanted was a pass-fail kind of thing so
I wondered if real_quick_ratio() might do the trick. But with the
following experiments:
1.0
It seems like there's no way to get real_quick_ratio() to say anything
except "it's a perfect match!" I'm wondering if someone didn't leave a
code stub unwritten:
def real_quick_ratio(self): return 1.0
[Bruce Eckel]
...What I'd like to do is find an algorithm that produces the results of
a text comparison as a percentage-match. Thus I would be able to
assert that my test samples must match the control sample by at least
(for example) 83% for the test to pass.
SequenceMatcher works on sequences of hashable elements. Above, it's
working on sequence of characters (aka "strings" <wink>). Other
possibilites include sequences of lines ("files") and lists of
integers.
Bruce Eckel http://www.BruceEckel.com mailto:[email protected]
Contains electronic books: "Thinking in Java 3e" & "Thinking in C++ 2e"
Web log: http://www.mindview.net/WebLog
Subscribe to my newsletter:
http://www.mindview.net/Newsletter
My schedule can be found at:
http://www.mindview.net/Calendar
"The whole problem with the world is that fools and fanatics are always
so certain of themselves, and wiser people so full of doubts."
--Bertrand Russell