Home | Trees | Indices | Help |
---|
|
Produce special diffs between strings and other interesting objects.
Author: Chusslove Illich (Часлав Илић) <caslav.ilic@gmx.net>
License: GPLv3
Functions | |||
[(string, element)...] or ([(string, element)...], float) |
|
||
[(string, element)...] or ([(string, element)...], float) |
|
||
[(string, string)...] or ([(string, string)...], float) |
|
||
string/ColorString/None or (string/ColorString/None, float) |
|
||
string or None |
|
||
string or None |
|
||
string or list or None |
|
||
string or list or None |
|
||
[[(string, string)...]...] or ([([(string, string)...], float)...], float) |
|
||
[string...] or ([(string, float)...], float) |
|
||
list of strings |
|
||
list of strings |
|
||
list of index tuples |
|
||
[(string, int/None, [(string, string)...])...] or ([(string, int/None, [(string, string)...], float)...], float) |
|
||
type(emsg or msg2 or msg1 or None) or (type(~), float) |
|
||
type of first non-None of rmsg, emsg, or None |
|
||
|
|||
float |
|
||
None or float or (float, int, int)
|
|
Variables | |
__package__ =
|
|
x =
|
Function Details |
Create tagged difference of two sequences. Difference is presented as a list of tuples, with each tuple composed
of a difference tag and a sequence element. Difference tag is string
The list is ordered such that collecting all elements not tagged as old will reconstruct the new sequence, and collecting all not tagged as new will reconstruct the old sequence. If requested by the Examples: >>> s1 = "A type of foo".split() >>> s2 = "A kind of foo".split() >>> tdiff(s1, s2) [(' ', 'A'), ('-', 'type'), ('+', 'kind'), (' ', 'of'), (' ', 'foo')] >>> tdiff(s1, s2, diffr=True) ([(' ', 'A'), ('-', 'type'), ('+', 'kind'), (' ', 'of'), (' ', 'foo')], 0.25) To be able to diff them, sequence elements only need to be hashable.
However, for compound elements it may be better to diff them only by some
subset of data, e.g. by one of their string attributes. Parameter
|
Create interleaved tagged difference of two sequences. Similar to tdiff, except that blocks of added/removed elements are further heuristically interleaved by similarity, such that each removed element may be followed by a similar added element, if such has been determined. This is useful e.g. to be able to afterwards make inner difference of each two paired similar elements (e.g. word diff within line diff). Example: >>> s1 = "Two blue airplanes".split() >>> s2 = "Two bluish ships".split() >>> tdiff(s1, s2) [(' ', 'Two'), ('-', 'blue'), ('-', 'airplanes'), ('+', 'bluish'), ('+', 'ships')] >>> itdiff(s1, s2) [(' ', 'Two'), ('-', 'blue'), ('+', 'bluish'), ('-', 'airplanes'), ('+', 'ships')] To be able to interleave blocks, each element in turn must be a
sequence in its own. This means that function supplied by
Parameter
|
Create word-level difference between old and new text. The difference is computed by looking at texts as collections of words
and intersegments. Difference is presented as a list of tuples, with each
tuple composed of a difference tag and a text segment. Difference tag is
string The list is ordered such that joining all text segments not marked as old will reconstruct the new text, and joining all not marked as new will reconstruct the old text. If requested by the Differencing may take into account when the texts are expected to have XML-like markup, or when they are of certain format defined by Gettext. Examples: >>> s1 = "A new type of foo." >>> s2 = "A new kind of foo." >>> word_diff(s1, s2) [(' ', 'A new '), ('+', 'kind'), ('-', 'type'), (' ', ' of foo.')] >>> word_diff(s1, s2, diffr=True) ([(' ', 'A new '), ('+', 'kind'), ('-', 'type'), (' ', ' of foo.')], 0.36363636363636365) >>> word_diff(s1, None, diffr=True) ([('-~', 'A new type of foo.')], 1.0) >>> word_diff(None, s2, diffr=True) ([('+~', 'A new kind of foo.')], 1.0)
|
Create word-level embedded difference between old and new texts. Same as word_diff, but the difference is returned as text in
which the new segments are wrapped as If one of the texts is The See word_diff for description of other parameters.
See Also: word_diff |
Recover old version (-) from text with embedded differences. In case there was no old text,
See Also: word_ediff |
Recover new version (+) from text with embedded differences. In case there was no new text,
See Also: word_ediff |
Recover removed segments (-) from text with embedded differences. If separator is not
See Also: word_ediff |
Recover added segments (+) from text with embedded differences. If separator is not
See Also: word_ediff |
Create word-level difference between old and new lines of text. First makes a difference on a line-level, and then for each set of differing lines a difference on word-level, using word_diff. Difference is presented as a list of tuples of word diffs and ratios as constructed by word_diff. See word_diff for description of keyword parameters. The difference ratio is computed as line-length weighted average of word difference ratios per line.
|
Create word-level embedded difference between old and new lines of text. Same as line_diff, but the difference is returned as list of
tuples of line of text (in which the new segments are wrapped as
See Also: line_diff |
Recover old version (-) from lines of text with embedded differences.
See Also: line_ediff |
Recover new version (+) from lines of text with embedded differences.
See Also: line_ediff |
Adapt matched spans in filtered text to original text. Sometimes text gets filtered before being matched, and when a match is found in the filtered text, it needs to be reported relative to the original text. This function will heuristically adapt matched spans relative to the filtered text back to the original text. Spans are given as list of index tuples Span tuples may have more elements past the start and end indices. They will be ignored, but preserved; if merging is in effect, extra elements will be preserved for only the frontmost of the overlapping spans (undefined for which if there are several). If an input span is invalid in any way, it is carried over verbatim into result.
|
Create word-level difference between extraction-invariant parts of messages. For which parts of a message are considered extraction-invariant, see description of inv instance variable of message objects. There are two return modes, depending on the value of
If If Either of the messages can be given as Every Instead of constructing the full difference, using the
|
Create word-level embedded difference between extraction-invariant parts of messages. Like msg_diff, but instead of difference list the result is a
message with embedded differences, of the kind produced by word_ediff.
See msg_diff
for description By default, a new message with embedded difference will be
constructed, of the type of first non-None of If resulting messages with embedded differences are to be inserted
into a catalog, that catalog can be given by the An additional automatic comment starting with
By default the difference comment is not added if there are no
indicators, but it may be forced by setting Embedded differences can be additionally colorized (e.g. for terminal)
by setting If
|
Resolve message with embedded difference to the newer message. Message cannot be properly resolved if By default a new message object is created, but using the
If the resolved message evaluates to no message, the function returns
Any states indicated as added by the difference comment are ignored in favor of the actual states of embedded difference message. The two sets should normally be equal, but if they are not, the actual state in effect overrides the indicated added state.
|
Resolve message with embedded difference to the older message. Like msg_ediff_to_new, only constructing the opposite message (except that states indicated as removed by difference comment are never ignored, i.e. they always override actual states). See msg_ediff_to_new for parameters and return values. |
Compute the probability that a human would rather edit the old text to obtain the new text, then write it from scratch. Classical algorithms to compute similarity ratio between two texts sometimes produce high ratios for texts which a human would unlikely consider similar enough to make one text by editing the other, and vice versa. This functions uses some heuristics to derive the probability that one text was really edited by a human into the other. Not commutative in general. If one of the texts is given as
|
Compute the probability that one PO file is a descendant of another. Sometimes PO files are renamed, split into two, joined into one, also
with possible small changes in messages between old and new set. This
functions uses some heuristics to derive the probability that the PO file
given by By default, only equality versus non-equality of messages is taken
into consideration. If
|
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Thu Jul 24 21:00:26 2014 | http://epydoc.sourceforge.net |