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

Class InsensitiveSequenceMatcher

SequenceMatcher --+
                  |
                 InsensitiveSequenceMatcher


Acts like SequenceMatcher, but tries not to find very small equal blocks amidst large spans of changes
Method Summary
  get_matching_blocks(self)
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.
  get_opcodes(self)
Return list of 5-tuples describing how to turn a into b.
  quick_ratio(self)
Return an upper bound on ratio() relatively quickly.
  ratio(self)
Return a measure of the sequences' similarity (float in [0,1]).
  real_quick_ratio(self)
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

get_matching_blocks(self)

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)]
Overrides:
difflib.SequenceMatcher.get_matching_blocks (inherited documentation)

Class Variable Details

threshold

Type:
int
Value:
2                                                                     

Generated by Epydoc 2.1 on Sat Aug 18 12:44:27 2007 http://epydoc.sf.net