Click or drag to resize

DiffMatchPatch Class

Class containing the diff, match and patch methods. Also Contains the behavior settings.
Inheritance Hierarchy
SystemObject
  GSF.TextDiffMatchPatch

Namespace: GSF.Text
Assembly: GSF.Core (in GSF.Core.dll) Version: 2.4.207-beta+1781b796b2aa7a54013a031eb432fe4ccee31867
Syntax
public class DiffMatchPatch
View Source

The DiffMatchPatch type exposes the following members.

Constructors
 NameDescription
Public methodDiffMatchPatchInitializes a new instance of the DiffMatchPatch class
Top
Methods
 NameDescription
Protected methodDiffBisect

Find the 'middle snake' of a diff, split the problem in two and return the recursively constructed diff.

See Myers 1986 paper: An O(ND) Difference Algorithm and Its Variations.

Protected methodDiffCharsToLines Rehydrate the text in a diff from a string of line hashes to real lines of text.
Public methodDiffCleanupEfficiency Reduce the number of edits by eliminating operationally trivial equalities.
Public methodDiffCleanupMerge Reorder and merge like edit sections. Merge equalities. Any edit section can move as long as it doesn't cross an equality.
Public methodDiffCleanupSemantic Reduce the number of edits by eliminating semantically trivial equalities.
Public methodDiffCleanupSemanticLossless Look for single edits surrounded on both sides by equalities which can be shifted sideways to align the edit to a word boundary. e.g: The cat came. -> The cat came.
Protected methodDiffCommonOverlap Determine if the suffix of one string is the prefix of another.
Public methodDiffCommonPrefix Determine the common prefix of two strings.
Public methodDiffCommonSuffix Determine the common suffix of two strings.
Public methodDiffFromDelta Given the original text1, and an encoded string which describes the operations required to transform text1 into text2, compute the full diff.
Protected methodDiffHalfMatch Do the two texts share a Substring which is at least half the length of the longer text? This speedup can produce non-minimal diffs.
Public methodDiffLevenshtein Compute the Levenshtein distance; the number of inserted, deleted or substituted characters.
Protected methodDiffLinesToChars Split two texts into a list of strings. Reduce the texts to a string of hashes where each Unicode character represents one line.
Public methodDiffMain(String, String) Find the differences between two texts. Run a faster, slightly less optimal diff. This method allows the 'checklines' of DiffMain() to be optional. Most of the time checklines is wanted, so default to true.
Public methodDiffMain(String, String, Boolean) Find the differences between two texts.
Public methodDiffPrettyHtml Convert a Diff list into a pretty HTML report.
Public methodDiffText1 Compute and return the source text (all equalities and deletions).
Public methodDiffText2 Compute and return the destination text (all equalities and insertions).
Public methodDiffToDelta Crush the diff into an encoded string which describes the operations required to transform text1 into text2. E.g. =3\t-2\t+ing -> Keep 3 chars, delete 2 chars, insert 'ing'. Operations are tab-separated. Inserted text is escaped using %xx notation.
Public methodDiffXIndex loc is a location in text1, compute and return the equivalent location in text2. e.g. "The cat" vs "The big cat", 1->1, 5->8
Public methodStatic memberEncodeURI Encodes a string with URI-style % escaping. Compatible with JavaScript's encodeURI function.
Public methodEqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object)
Public methodGetHashCodeServes as the default hash function.
(Inherited from Object)
Public methodGetTypeGets the Type of the current instance.
(Inherited from Object)
Protected methodMatchAlphabet Initialize the alphabet for the Bitap algorithm.
Protected methodMatchBitap Locate the best instance of 'pattern' in 'text' near 'loc' using the Bitap algorithm. Returns -1 if no match found.
Public methodMatchMain Locate the best instance of 'pattern' in 'text' near 'loc'. Returns -1 if no match found.
Protected methodMemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
Protected methodPatchAddContext Increase the context until it is unique, but don't let the pattern expand beyond MatchMaxBits.
Public methodPatchAddPadding Add some padding on text start and end so that edges can match something. Intended to be called only from within PatchApply.
Public methodPatchApply Merge a set of patches onto the text. Return a patched text, as well as an array of true/false values indicating which patches were applied.
Public methodPatchDeepCopy Given an array of patches, return another array that is identical.
Public methodPatchFromText Parse a textual representation of patches and return a List of Patch objects.
Public methodPatchMake(ListDiff) Compute a list of patches to turn text1 into text2. text1 will be derived from the provided diffs.
Public methodPatchMake(String, ListDiff) Compute a list of patches to turn text1 into text2. text2 is not provided, diffs are the delta between text1 and text2.
Public methodPatchMake(String, String) Compute a list of patches to turn text1 into text2. A set of diffs will be computed.
Public methodPatchMake(String, String, ListDiff)Obsolete.
Compute a list of patches to turn text1 into text2. text2 is ignored, diffs are the delta between text1 and text2.
Public methodPatchSplitMax Look through the patches and break up any which are longer than the maximum limit of the match algorithm. Intended to be called only from within PatchApply.
Public methodPatchToText Take a list of patches and return a textual representation.
Public methodToStringReturns a string that represents the current object.
(Inherited from Object)
Top
Fields
 NameDescription
Public fieldDiffEditCost Cost of an empty edit operation in terms of edit characters.
Public fieldDiffTimeout Number of seconds to map a diff before giving up (0 for infinity).
Public fieldMatchDistance How far to search for a match (0 = exact location, 1000+ = broad match). A match this many characters away from the expected location will add 1.0 to the score (0.0 is a perfect match).
Public fieldMatchThreshold At what point is no match declared (0.0 = perfection, 1.0 = very loose).
Public fieldPatchDeleteThreshold When deleting a large block of text (over ~64 characters), how close do the contents have to be to match the expected contents. (0.0 = perfection, 1.0 = very loose). Note that MatchThreshold controls how closely the end points of a delete need to match.
Public fieldPatchMargin Chunk size for context length.
Top
Extension Methods
 NameDescription
Public Extension MethodGetEnumValueOrDefault Gets the enumeration constant for value, if defined in the enumeration, or a default value.
(Defined by EnumExtensions)
Public Extension MethodGetEnumValueOrDefaultT Gets the enumeration constant for this value, if defined in the enumeration, or a default value.
(Defined by EnumExtensions)
Top
See Also