update test_difflib from CPython3.11.2 by Reid00 · Pull Request #5063 · RustPython/RustPython
Methods:
__init__(isjunk=None, a='', b='') Construct a SequenceMatcher.
set_seqs(a, b) Set the two sequences to be compared.
set_seq1(a) Set the first sequence to be compared.
set_seq2(b) Set the second sequence to be compared.
find_longest_match(alo, ahi, blo, bhi) Find longest matching block in a[alo:ahi] and b[blo:bhi].
get_matching_blocks() Return list of triples describing matching subsequences.
get_opcodes() Return list of 5-tuples describing how to turn a into b.
ratio() Return a measure of the sequences' similarity (float in [0,1]).
quick_ratio() Return an upper bound on .ratio() relatively quickly.
real_quick_ratio() Return an upper bound on ratio() very quickly. """
def __init__(self, isjunk=None, a='', b='', autojunk=True):
def find_longest_match(self, alo, ahi, blo, bhi): def find_longest_match(self, alo=0, ahi=None, blo=0, bhi=None): """Find longest matching block in a[alo:ahi] and b[blo:bhi].
By default it will find the longest match in the entirety of a and b.
If isjunk is not defined:
Return (i,j,k) such that a[i:i+k] is equal to b[j:j+k], where
a, b, b2j, isbjunk = self.a, self.b, self.b2j, self.bjunk.__contains__ if ahi is None: ahi = len(a) if bhi is None: bhi = len(b) besti, bestj, bestsize = alo, blo, 0 # find longest junk-free match # during an iteration of the loop, j2len[j] = length of longest
__class_getitem__ = classmethod(GenericAlias)
def get_close_matches(word, possibilities, n=3, cutoff=0.6): """Use SequenceMatcher to return list of the best "good enough" matches.
Methods:
__init__(linejunk=None, charjunk=None) Construct a text differencer, with optional filters.
compare(a, b) Compare two sequences of lines; generate the resulting delta. """
def __init__(self, linejunk=None, charjunk=None):
Example: