@@ -62,7 +62,7 @@ class SequenceMatcher:
6262 notion, pairing up elements that appear uniquely in each sequence.
6363 That, and the method here, appear to yield more intuitive difference
6464 reports than does diff. This method appears to be the least vulnerable
65- tosynching up on blocks of "junk lines", though (like blank lines in
65+ tosyncing up on blocks of "junk lines", though (like blank lines in
6666 ordinary text files, or maybe "<P>" lines in HTML files). That may be
6767 because this is the only method of the 3 that has a *concept* of
6868 "junk" <wink>.
@@ -115,38 +115,6 @@ class SequenceMatcher:
115115 case. SequenceMatcher is quadratic time for the worst case and has
116116 expected-case behavior dependent in a complicated way on how many
117117 elements the sequences have in common; best case time is linear.
118-
119- Methods:
120-
121- __init__(isjunk=None, a='', b='')
122- Construct a SequenceMatcher.
123-
124- set_seqs(a, b)
125- Set the two sequences to be compared.
126-
127- set_seq1(a)
128- Set the first sequence to be compared.
129-
130- set_seq2(b)
131- Set the second sequence to be compared.
132-
133- find_longest_match(alo, ahi, blo, bhi)
134- Find longest matching block in a[alo:ahi] and b[blo:bhi].
135-
136- get_matching_blocks()
137- Return list of triples describing matching subsequences.
138-
139- get_opcodes()
140- Return list of 5-tuples describing how to turn a into b.
141-
142- ratio()
143- Return a measure of the sequences' similarity (float in [0,1]).
144-
145- quick_ratio()
146- Return an upper bound on .ratio() relatively quickly.
147-
148- real_quick_ratio()
149- Return an upper bound on ratio() very quickly.
150118 """
151119
152120def __init__ (self ,isjunk = None ,a = '' ,b = '' ,autojunk = True ):
@@ -334,9 +302,11 @@ def __chain_b(self):
334302for elt in popular :# ditto; as fast for 1% deletion
335303del b2j [elt ]
336304
337- def find_longest_match (self ,alo ,ahi ,blo ,bhi ):
305+ def find_longest_match (self ,alo = 0 ,ahi = None ,blo = 0 ,bhi = None ):
338306"""Find longest matching block in a[alo:ahi] and b[blo:bhi].
339307
308+ By default it will find the longest match in the entirety of a and b.
309+
340310 If isjunk is not defined:
341311
342312 Return (i,j,k) such that a[i:i+k] is equal to b[j:j+k], where
@@ -391,6 +361,10 @@ def find_longest_match(self, alo, ahi, blo, bhi):
391361# the unique 'b's and then matching the first two 'a's.
392362
393363a ,b ,b2j ,isbjunk = self .a ,self .b ,self .b2j ,self .bjunk .__contains__
364+ if ahi is None :
365+ ahi = len (a )
366+ if bhi is None :
367+ bhi = len (b )
394368besti ,bestj ,bestsize = alo ,blo ,0
395369# find longest junk-free match
396370# during an iteration of the loop, j2len[j] = length of longest
@@ -688,6 +662,7 @@ def real_quick_ratio(self):
688662
689663__class_getitem__ = classmethod (GenericAlias )
690664
665+
691666def get_close_matches (word ,possibilities ,n = 3 ,cutoff = 0.6 ):
692667"""Use SequenceMatcher to return list of the best "good enough" matches.
693668
@@ -830,14 +805,6 @@ class Differ:
830805 + 4. Complicated is better than complex.
831806 ? ++++ ^ ^
832807 + 5. Flat is better than nested.
833-
834- Methods:
835-
836- __init__(linejunk=None, charjunk=None)
837- Construct a text differencer, with optional filters.
838-
839- compare(a, b)
840- Compare two sequences of lines; generate the resulting delta.
841808 """
842809
843810def __init__ (self ,linejunk = None ,charjunk = None ):
@@ -870,7 +837,7 @@ def compare(self, a, b):
870837 Each sequence must contain individual single-line strings ending with
871838 newlines. Such sequences can be obtained from the `readlines()` method
872839 of file-like objects. The delta generated also consists of newline-
873- terminated strings, ready to be printed as-is via thewriteline ()
840+ terminated strings, ready to be printed as-is via thewritelines ()
874841 method of a file-like object.
875842
876843 Example: