mirror of https://github.com/python/cpython
Improve accuracy. In the .tex file, note the new "% BUG:" comments: an
extra backslash is getting displayed in the generated HTML.
This commit is contained in:
parent
f0768c822b
commit
754ba589b7
|
@ -53,8 +53,8 @@
|
||||||
\strong{Timing:} The basic Ratcliff-Obershelp algorithm is cubic
|
\strong{Timing:} The basic Ratcliff-Obershelp algorithm is cubic
|
||||||
time in the worst case and quadratic time in the expected case.
|
time in the worst case and quadratic time in the expected case.
|
||||||
\class{SequenceMatcher} is quadratic time for the worst case and has
|
\class{SequenceMatcher} is quadratic time for the worst case and has
|
||||||
expected-case behavior dependent on how many elements the sequences
|
expected-case behavior dependent in a complicated way on how many
|
||||||
have in common; best case time (no elements in common) is linear.
|
elements the sequences have in common; best case time is linear.
|
||||||
\end{classdesc}
|
\end{classdesc}
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,6 +68,9 @@
|
||||||
\code{None} is equivalent to passing \code{lambda x: 0}, i.e.\ no
|
\code{None} is equivalent to passing \code{lambda x: 0}, i.e.\ no
|
||||||
elements are ignored. For example, pass
|
elements are ignored. For example, pass
|
||||||
|
|
||||||
|
% BUG: the HTML generated for this is
|
||||||
|
% BUG: lambda x: x in " \\t"
|
||||||
|
% BUG: i.e. it displays two backslashes.
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
lambda x: x in " \\t"
|
lambda x: x in " \\t"
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
@ -138,7 +141,7 @@ of the other sequences.
|
||||||
junk happens to be adjacent to an interesting match.
|
junk happens to be adjacent to an interesting match.
|
||||||
|
|
||||||
Here's the same example as before, but considering blanks to be junk.
|
Here's the same example as before, but considering blanks to be junk.
|
||||||
That prevents \code{' abcd'} from matching the \code{ abcd} at the
|
That prevents \code{' abcd'} from matching the \code{' abcd'} at the
|
||||||
tail end of the second sequence directly. Instead only the
|
tail end of the second sequence directly. Instead only the
|
||||||
\code{'abcd'} can match, and matches the leftmost \code{'abcd'} in
|
\code{'abcd'} can match, and matches the leftmost \code{'abcd'} in
|
||||||
the second sequence:
|
the second sequence:
|
||||||
|
@ -217,8 +220,8 @@ replace a[3:4] (x) b[2:3] (y)
|
||||||
range [0, 1].
|
range [0, 1].
|
||||||
|
|
||||||
Where T is the total number of elements in both sequences, and M is
|
Where T is the total number of elements in both sequences, and M is
|
||||||
the number of matches, this is 2,0*M / T. Note that this is \code{1}
|
the number of matches, this is 2.0*M / T. Note that this is \code{1.}
|
||||||
if the sequences are identical, and \code{0} if they have nothing in
|
if the sequences are identical, and \code{0.} if they have nothing in
|
||||||
common.
|
common.
|
||||||
|
|
||||||
This is expensive to compute if \method{get_matching_blocks()} or
|
This is expensive to compute if \method{get_matching_blocks()} or
|
||||||
|
@ -242,8 +245,10 @@ replace a[3:4] (x) b[2:3] (y)
|
||||||
\method{ratio()} or \method{quick_ratio()}.
|
\method{ratio()} or \method{quick_ratio()}.
|
||||||
\end{methoddesc}
|
\end{methoddesc}
|
||||||
|
|
||||||
The three methods that return the ratio of differences to similarities
|
The three methods that return the ratio of matching to total characters
|
||||||
can give different results due to differing levels of approximation:
|
can give different results due to differing levels of approximation,
|
||||||
|
although \method{quick_ratio()} and \method{real_quick_ratio()} are always
|
||||||
|
at least as large as \method{ratio()}:
|
||||||
|
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
>>> s = SequenceMatcher(None, "abcd", "bcde")
|
>>> s = SequenceMatcher(None, "abcd", "bcde")
|
||||||
|
|
|
@ -92,9 +92,9 @@ See also function get_close_matches() in this module, which shows how
|
||||||
simple code building on SequenceMatcher can be used to do useful work.
|
simple code building on SequenceMatcher can be used to do useful work.
|
||||||
|
|
||||||
Timing: Basic R-O is cubic time worst case and quadratic time expected
|
Timing: Basic R-O is cubic time worst case and quadratic time expected
|
||||||
case. SequenceMatcher is quadratic time worst case and has expected-case
|
case. SequenceMatcher is quadratic time for the worst case and has
|
||||||
behavior dependent on how many elements the sequences have in common; best
|
expected-case behavior dependent in a complicated way on how many
|
||||||
case time (no elements in common) is linear.
|
elements the sequences have in common; best case time is linear.
|
||||||
|
|
||||||
SequenceMatcher methods:
|
SequenceMatcher methods:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue