Package lxml :: Package html :: Module diff :: Class InsensitiveSequenceMatcher
[show private | hide private]
[frames | no frames]

Class InsensitiveSequenceMatcher

SequenceMatcher --+

Acts like SequenceMatcher, but tries not to find very small equal blocks amidst large spans of changes
Method Summary
Return list of triples describing matching subsequences.
    Inherited from SequenceMatcher
  __init__(self, isjunk, a, b)
Construct a SequenceMatcher.
  find_longest_match(self, alo, ahi, blo, bhi)
Find longest matching block in a[alo:ahi] and b[blo:bhi].
  get_grouped_opcodes(self, n)
Isolate change clusters by eliminating ranges with no changes.
Return list of 5-tuples describing how to turn a into b.
Return an upper bound on ratio() relatively quickly.
Return a measure of the sequences' similarity (float in [0,1]).
Return an upper bound on ratio() very quickly.
  set_seq1(self, a)
Set the first sequence to be compared.
  set_seq2(self, b)
Set the second sequence to be compared.
  set_seqs(self, a, b)
Set the two sequences to be compared.

Class Variable Summary
int threshold = 2                                                                     

Method Details


Return list of triples describing matching subsequences.

Each triple is of the form (i, j, n), and means that a[i:i+n] == b[j:j+n]. The triples are monotonically increasing in i and in j. New in Python 2.5, it's also guaranteed that if (i, j, n) and (i', j', n') are adjacent triples in the list, and the second is not the last triple in the list, then i+n != i' or j+n != j'. IOW, adjacent triples never describe adjacent equal blocks.

The last triple is a dummy, (len(a), len(b), 0), and is the only triple with n==0.
>>> s = SequenceMatcher(None, "abxcd", "abcd")
>>> s.get_matching_blocks()
[(0, 0, 2), (3, 2, 2), (5, 4, 0)]
difflib.SequenceMatcher.get_matching_blocks (inherited documentation)

Class Variable Details



Generated by Epydoc 2.1 on Sat Aug 18 12:44:27 2007