|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectorg.test4j.tools.commons.TextDiffMatchPatch
public class TextDiffMatchPatch
Class containing the diff, match and patch methods. Also contains the behaviour settings.
| 嵌套类摘要 | |
|---|---|
static class |
TextDiffMatchPatch.Diff
Class representing one diff operation. |
protected static class |
TextDiffMatchPatch.LinesToCharsResult
Internal class for returning results from diff_linesToChars(). |
static class |
TextDiffMatchPatch.Operation
The data structure representing a diff is a Linked list of Diff objects: {Diff(Operation.DELETE, "Hello"), Diff(Operation.INSERT, "Goodbye"), Diff(Operation.EQUAL, " world.")} which means: delete "Hello", add "Goodbye" and keep " world." |
static class |
TextDiffMatchPatch.Patch
Class representing one patch operation. |
| 字段摘要 | |
|---|---|
short |
Diff_EditCost
Cost of an empty edit operation in terms of edit characters. |
float |
Diff_Timeout
Number of seconds to map a diff before giving up (0 for infinity). |
int |
Match_Distance
How far to search for a match (0 = exact location, 1000+ = broad match). |
float |
Match_Threshold
At what point is no match declared (0.0 = perfection, 1.0 = very loose). |
float |
Patch_DeleteThreshold
When deleting a large block of text (over ~64 characters), how close does the contents have to match the expected contents. (0.0 = perfection, 1.0 = very loose). |
short |
Patch_Margin
Chunk size for context length. |
| 构造方法摘要 | |
|---|---|
TextDiffMatchPatch()
|
|
| 方法摘要 | |
|---|---|
protected LinkedList<TextDiffMatchPatch.Diff> |
diff_bisect(String text1,
String text2,
long deadline)
Find the 'middle snake' of a diff, split the problem in two and return the recursively constructed diff. |
protected void |
diff_charsToLines(LinkedList<TextDiffMatchPatch.Diff> diffs,
List<String> lineArray)
Rehydrate the text in a diff from a string of line hashes to real lines of text. |
void |
diff_cleanupEfficiency(LinkedList<TextDiffMatchPatch.Diff> diffs)
Reduce the number of edits by eliminating operationally trivial equalities. |
void |
diff_cleanupMerge(LinkedList<TextDiffMatchPatch.Diff> diffs)
Reorder and merge like edit sections. |
void |
diff_cleanupSemantic(LinkedList<TextDiffMatchPatch.Diff> diffs)
Reduce the number of edits by eliminating semantically trivial equalities. |
void |
diff_cleanupSemanticLossless(LinkedList<TextDiffMatchPatch.Diff> diffs)
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 int |
diff_commonOverlap(String text1,
String text2)
Determine if the suffix of one string is the prefix of another. |
int |
diff_commonPrefix(String text1,
String text2)
Determine the common prefix of two strings |
int |
diff_commonSuffix(String text1,
String text2)
Determine the common suffix of two strings |
LinkedList<TextDiffMatchPatch.Diff> |
diff_fromDelta(String text1,
String delta)
Given the original text1, and an encoded string which describes the operations required to transform text1 into text2, compute the full diff. |
protected String[] |
diff_halfMatch(String text1,
String text2)
Do the two texts share a substring which is at least half the length of the longer text? |
int |
diff_levenshtein(LinkedList<TextDiffMatchPatch.Diff> diffs)
Compute the Levenshtein distance; the number of inserted, deleted or substituted characters. |
protected TextDiffMatchPatch.LinesToCharsResult |
diff_linesToChars(String text1,
String text2)
Split two texts into a list of strings. |
LinkedList<TextDiffMatchPatch.Diff> |
diff_main(String text1,
String text2)
Find the differences between two texts. |
LinkedList<TextDiffMatchPatch.Diff> |
diff_main(String text1,
String text2,
boolean checklines)
Find the differences between two texts. |
String |
diff_prettyHtml(LinkedList<TextDiffMatchPatch.Diff> diffs)
Convert a Diff list into a pretty HTML report. |
String |
diff_text1(LinkedList<TextDiffMatchPatch.Diff> diffs)
Compute and return the source text (all equalities and deletions). |
String |
diff_text2(LinkedList<TextDiffMatchPatch.Diff> diffs)
Compute and return the destination text (all equalities and insertions). |
String |
diff_toDelta(LinkedList<TextDiffMatchPatch.Diff> diffs)
Crush the diff into an encoded string which describes the operations required to transform text1 into text2. |
int |
diff_xIndex(LinkedList<TextDiffMatchPatch.Diff> diffs,
int loc)
loc is a location in text1, compute and return the equivalent location in text2. e.g. |
protected Map<Character,Integer> |
match_alphabet(String pattern)
Initialise the alphabet for the Bitap algorithm. |
protected int |
match_bitap(String text,
String pattern,
int loc)
Locate the best instance of 'pattern' in 'text' near 'loc' using the Bitap algorithm. |
int |
match_main(String text,
String pattern,
int loc)
Locate the best instance of 'pattern' in 'text' near 'loc'. |
protected void |
patch_addContext(TextDiffMatchPatch.Patch patch,
String text)
Increase the context until it is unique, but don't let the pattern expand beyond Match_MaxBits. |
String |
patch_addPadding(LinkedList<TextDiffMatchPatch.Patch> patches)
Add some padding on text start and end so that edges can match something. |
Object[] |
patch_apply(LinkedList<TextDiffMatchPatch.Patch> patches,
String text)
Merge a set of patches onto the text. |
LinkedList<TextDiffMatchPatch.Patch> |
patch_deepCopy(LinkedList<TextDiffMatchPatch.Patch> patches)
Given an array of patches, return another array that is identical. |
List<TextDiffMatchPatch.Patch> |
patch_fromText(String textline)
Parse a textual representation of patches and return a List of Patch objects. |
LinkedList<TextDiffMatchPatch.Patch> |
patch_make(LinkedList<TextDiffMatchPatch.Diff> diffs)
Compute a list of patches to turn text1 into text2. text1 will be derived from the provided diffs. |
LinkedList<TextDiffMatchPatch.Patch> |
patch_make(String text1,
LinkedList<TextDiffMatchPatch.Diff> diffs)
Compute a list of patches to turn text1 into text2. text2 is not provided, diffs are the delta between text1 and text2. |
LinkedList<TextDiffMatchPatch.Patch> |
patch_make(String text1,
String text2)
Compute a list of patches to turn text1 into text2. |
LinkedList<TextDiffMatchPatch.Patch> |
patch_make(String text1,
String text2,
LinkedList<TextDiffMatchPatch.Diff> diffs)
已过时。 Prefer patch_make(String text1, LinkedList |
void |
patch_splitMax(LinkedList<TextDiffMatchPatch.Patch> patches)
Look through the patches and break up any which are longer than the maximum limit of the match algorithm. |
String |
patch_toText(List<TextDiffMatchPatch.Patch> patches)
Take a list of patches and return a textual representation. |
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 字段详细信息 |
|---|
public float Diff_Timeout
public short Diff_EditCost
public float Match_Threshold
public int Match_Distance
public float Patch_DeleteThreshold
public short Patch_Margin
| 构造方法详细信息 |
|---|
public TextDiffMatchPatch()
| 方法详细信息 |
|---|
public LinkedList<TextDiffMatchPatch.Diff> diff_main(String text1,
String text2)
text1 - Old string to be diffed.text2 - New string to be diffed.
public LinkedList<TextDiffMatchPatch.Diff> diff_main(String text1,
String text2,
boolean checklines)
text1 - Old string to be diffed.text2 - New string to be diffed.checklines - Speedup flag. If false, then don't run a line-level diff first
to identify the changed areas. If true, then run a faster
slightly less optimal diff.
protected LinkedList<TextDiffMatchPatch.Diff> diff_bisect(String text1,
String text2,
long deadline)
text1 - Old string to be diffed.text2 - New string to be diffed.deadline - Time at which to bail if not yet complete.
protected TextDiffMatchPatch.LinesToCharsResult diff_linesToChars(String text1,
String text2)
text1 - First string.text2 - Second string.
protected void diff_charsToLines(LinkedList<TextDiffMatchPatch.Diff> diffs,
List<String> lineArray)
diffs - LinkedList of Diff objects.lineArray - List of unique strings.
public int diff_commonPrefix(String text1,
String text2)
text1 - First string.text2 - Second string.
public int diff_commonSuffix(String text1,
String text2)
text1 - First string.text2 - Second string.
protected int diff_commonOverlap(String text1,
String text2)
text1 - First string.text2 - Second string.
protected String[] diff_halfMatch(String text1,
String text2)
text1 - First string.text2 - Second string.
public void diff_cleanupSemantic(LinkedList<TextDiffMatchPatch.Diff> diffs)
diffs - LinkedList of Diff objects.public void diff_cleanupSemanticLossless(LinkedList<TextDiffMatchPatch.Diff> diffs)
diffs - LinkedList of Diff objects.public void diff_cleanupEfficiency(LinkedList<TextDiffMatchPatch.Diff> diffs)
diffs - LinkedList of Diff objects.public void diff_cleanupMerge(LinkedList<TextDiffMatchPatch.Diff> diffs)
diffs - LinkedList of Diff objects.
public int diff_xIndex(LinkedList<TextDiffMatchPatch.Diff> diffs,
int loc)
diffs - LinkedList of Diff objects.loc - Location within text1.
public String diff_prettyHtml(LinkedList<TextDiffMatchPatch.Diff> diffs)
diffs - LinkedList of Diff objects.
public String diff_text1(LinkedList<TextDiffMatchPatch.Diff> diffs)
diffs - LinkedList of Diff objects.
public String diff_text2(LinkedList<TextDiffMatchPatch.Diff> diffs)
diffs - LinkedList of Diff objects.
public int diff_levenshtein(LinkedList<TextDiffMatchPatch.Diff> diffs)
diffs - LinkedList of Diff objects.
public String diff_toDelta(LinkedList<TextDiffMatchPatch.Diff> diffs)
diffs - Array of diff tuples.
public LinkedList<TextDiffMatchPatch.Diff> diff_fromDelta(String text1,
String delta)
throws IllegalArgumentException
text1 - Source string for the diff.delta - Delta text.
IllegalArgumentException - If invalid input.
public int match_main(String text,
String pattern,
int loc)
text - The text to search.pattern - The pattern to search for.loc - The location to search around.
protected int match_bitap(String text,
String pattern,
int loc)
text - The text to search.pattern - The pattern to search for.loc - The location to search around.
protected Map<Character,Integer> match_alphabet(String pattern)
pattern - The text to encode.
protected void patch_addContext(TextDiffMatchPatch.Patch patch,
String text)
patch - The patch to grow.text - Source text.
public LinkedList<TextDiffMatchPatch.Patch> patch_make(String text1,
String text2)
text1 - Old text.text2 - New text.
public LinkedList<TextDiffMatchPatch.Patch> patch_make(LinkedList<TextDiffMatchPatch.Diff> diffs)
diffs - Array of diff tuples for text1 to text2.
public LinkedList<TextDiffMatchPatch.Patch> patch_make(String text1,
String text2,
LinkedList<TextDiffMatchPatch.Diff> diffs)
text1 - Old texttext2 - Ignored.diffs - Array of diff tuples for text1 to text2.
public LinkedList<TextDiffMatchPatch.Patch> patch_make(String text1,
LinkedList<TextDiffMatchPatch.Diff> diffs)
text1 - Old text.diffs - Array of diff tuples for text1 to text2.
public LinkedList<TextDiffMatchPatch.Patch> patch_deepCopy(LinkedList<TextDiffMatchPatch.Patch> patches)
patches - Array of patch objects.
public Object[] patch_apply(LinkedList<TextDiffMatchPatch.Patch> patches,
String text)
patches - Array of patch objectstext - Old text.
public String patch_addPadding(LinkedList<TextDiffMatchPatch.Patch> patches)
patches - Array of patch objects.
public void patch_splitMax(LinkedList<TextDiffMatchPatch.Patch> patches)
patches - LinkedList of Patch objects.public String patch_toText(List<TextDiffMatchPatch.Patch> patches)
patches - List of Patch objects.
public List<TextDiffMatchPatch.Patch> patch_fromText(String textline)
throws IllegalArgumentException
textline - Text representation of patches.
IllegalArgumentException - If invalid input.
|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||