PHP 클래스 diff_match_patch, diff_match_patch-php

파일 보기 프로젝트 열기: nuxodin/diff_match_patch-php 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$Diff_DualThreshold Double-ending is twice as fast, but less accurate.
$Diff_EditCost Cost of an empty edit operation in terms of edit characters.
$Diff_Timeout Number of seconds to map a diff before giving up (0 for infinity).
$Match_Distance 1.0 to the score (0.0 is a perfect match).
$Match_Threshold At what point is no match declared (0.0 = perfection, 1.0 = very loose).
$Patch_DeleteThreshold end points of a delete need to match.
$Patch_Margin Chunk size for context length.

공개 메소드들

메소드 설명
diff_charsToLines ( &$diffs, $lineArray ) Rehydrate the text in a diff from a string of line hashes to real lines of text.
diff_cleanupEfficiency ( &$diffs ) Reduce the number of edits by eliminating operationally trivial equalities.
diff_cleanupMerge ( &$diffs ) Reorder and merge like edit sections. Merge equalities.
diff_cleanupSemantic ( &$diffs ) Reduce the number of edits by eliminating semantically trivial equalities.
diff_cleanupSemanticLossless ( &$diffs ) Look for single edits surrounded on both sides by equalities which can be shifted sideways to align the edit to a word boundary.
diff_cleanupSemanticScore ( $one, $two ) : {number} Given two strings, compute a score representing whether the internal boundary falls on logical boundaries.
diff_commonPrefix ( $text1, $text2 ) : {number} Determine the common prefix of two strings
diff_commonSuffix ( $text1, $text2 ) : {number} Determine the common suffix of two strings
diff_compute ( $text1, $text2, $checklines ) : {Array.>} Find the differences between two texts. Assumes that the texts do not have any common prefix or suffix.
diff_fromDelta ( $text1, $delta ) : {Array.>} Given the original text1, and an encoded string which describes the operations required to transform text1 into text2, compute the full diff.
diff_halfMatch ( $text1, $text2 ) : {Array.?} Do the two texts share a mb_substring which is at least half the length of the longer text?
diff_halfMatchI ( $longtext, $shorttext, $i ) : {Array.?} Does a mb_substring of shorttext exist within longtext such that the mb_substring is at least half the length of longtext? Closure, but does not reference any external variables.
diff_levenshtein ( $diffs ) : {number} Compute the Levenshtein distance; the number of inserted, deleted or substituted characters.
diff_linesToChars ( $text1, $text2 ) : {Array.>} Split two texts into an array of strings. Reduce the texts to a string of hashes where each Unicode character represents one line.
diff_linesToCharsMunge ( $text, &$lineArray, &$lineHash ) : {string} Split a text into an array of strings. Reduce the texts to a string of hashes where each Unicode character represents one line.
diff_main ( $text1, $text2, $checklines = true ) : {Array.>} Find the differences between two texts. Simplifies the problem by stripping any common prefix or suffix off the texts before diffing.
diff_map ( $text1, $text2 ) : {Array.>?} Explore the intersection points between the two texts.
diff_path1 ( $v_map, $text1, $text2 ) : {Array.>} Work from the middle back to the start to determine the path.
diff_path2 ( $v_map, $text1, $text2 ) : {Array.>} Work from the middle back to the end to determine the path.
diff_prettyHtml ( $diffs ) : {string} Convert a diff array into a pretty HTML report.
diff_text1 ( $diffs ) : {string} Compute and return the source text (all equalities and deletions).
diff_text2 ( $diffs ) : {string} Compute and return the destination text (all equalities and insertions).
diff_toDelta ( $diffs ) : {string} Crush the diff into an encoded string which describes the operations required to transform text1 into text2.
diff_xIndex ( $diffs, $loc ) : {number} loc is a location in text1, compute and return the equivalent location in text2.
match_alphabet ( $pattern ) : {Object} Initialise the alphabet for the Bitap algorithm.
match_bitap ( $text, $pattern, $loc ) : {number} Locate the best instance of 'pattern' in 'text' near 'loc' using the Bitap algorithm.
match_bitapScore ( $e, $x, $pattern, $loc ) : {number} Compute and return the score for a match with e errors and x location.
match_main ( $text, $pattern, $loc ) : {number} Locate the best instance of 'pattern' in 'text' near 'loc'.
patch_addContext ( $patch, $text ) Increase the context until it is unique, but don't let the pattern expand beyond Match_MaxBits.
patch_addPadding ( &$patches ) : {string} Add some padding on text start and end so that edges can match something.
patch_apply ( $patches, $text ) : {Array.>} Merge a set of patches onto the text. Return a patched text, as well as a list of true/false values indicating which patches were applied.
patch_deepCopy ( $patches ) : {Array.} Given an array of patches, return another array that is identical.
patch_fromText ( $textline ) : {Array.} Parse a textual representation of patches and return a list of patch objects.
patch_make ( $a, $opt_b = null, $opt_c = null ) : {Array.} Compute a list of patches to turn text1 into text2.
patch_splitMax ( &$patches ) Look through the patches and break up any which are longer than the maximum limit of the match algorithm.
patch_toText ( $patches ) : {string} Take a list of patches and return a textual representation.

메소드 상세

diff_charsToLines() 공개 메소드

Rehydrate the text in a diff from a string of line hashes to real lines of text.
public diff_charsToLines ( &$diffs, $lineArray )

diff_cleanupEfficiency() 공개 메소드

Reduce the number of edits by eliminating operationally trivial equalities.
public diff_cleanupEfficiency ( &$diffs )

diff_cleanupMerge() 공개 메소드

Any edit section can move as long as it doesn't cross an equality.
public diff_cleanupMerge ( &$diffs )

diff_cleanupSemantic() 공개 메소드

Reduce the number of edits by eliminating semantically trivial equalities.
public diff_cleanupSemantic ( &$diffs )

diff_cleanupSemanticLossless() 공개 메소드

e.g: The cat came. -> The cat came.
public diff_cleanupSemanticLossless ( &$diffs )

diff_cleanupSemanticScore() 공개 메소드

Scores range from 5 (best) to 0 (worst). Closure, makes reference to regex patterns defined above.
public diff_cleanupSemanticScore ( $one, $two ) : {number}
리턴 {number}

diff_commonPrefix() 공개 메소드

Determine the common prefix of two strings
public diff_commonPrefix ( $text1, $text2 ) : {number}
리턴 {number}

diff_commonSuffix() 공개 메소드

Determine the common suffix of two strings
public diff_commonSuffix ( $text1, $text2 ) : {number}
리턴 {number}

diff_compute() 공개 메소드

Find the differences between two texts. Assumes that the texts do not have any common prefix or suffix.
public diff_compute ( $text1, $text2, $checklines ) : {Array.>}
리턴 {Array.>}

diff_fromDelta() 공개 메소드

Given the original text1, and an encoded string which describes the operations required to transform text1 into text2, compute the full diff.
public diff_fromDelta ( $text1, $delta ) : {Array.>}
리턴 {Array.>}

diff_halfMatch() 공개 메소드

Do the two texts share a mb_substring which is at least half the length of the longer text?
public diff_halfMatch ( $text1, $text2 ) : {Array.?}
리턴 {Array.?}

diff_halfMatchI() 공개 메소드

Does a mb_substring of shorttext exist within longtext such that the mb_substring is at least half the length of longtext? Closure, but does not reference any external variables.
public diff_halfMatchI ( $longtext, $shorttext, $i ) : {Array.?}
리턴 {Array.?}

diff_levenshtein() 공개 메소드

Compute the Levenshtein distance; the number of inserted, deleted or substituted characters.
public diff_levenshtein ( $diffs ) : {number}
리턴 {number}

diff_linesToChars() 공개 메소드

Split two texts into an array of strings. Reduce the texts to a string of hashes where each Unicode character represents one line.
public diff_linesToChars ( $text1, $text2 ) : {Array.>}
리턴 {Array.>}

diff_linesToCharsMunge() 공개 메소드

Modifies linearray and linehash through being a closure.
public diff_linesToCharsMunge ( $text, &$lineArray, &$lineHash ) : {string}
리턴 {string}

diff_main() 공개 메소드

Find the differences between two texts. Simplifies the problem by stripping any common prefix or suffix off the texts before diffing.
public diff_main ( $text1, $text2, $checklines = true ) : {Array.>}
리턴 {Array.>}

diff_map() 공개 메소드

Explore the intersection points between the two texts.
public diff_map ( $text1, $text2 ) : {Array.>?}
리턴 {Array.>?}

diff_path1() 공개 메소드

Work from the middle back to the start to determine the path.
public diff_path1 ( $v_map, $text1, $text2 ) : {Array.>}
리턴 {Array.>}

diff_path2() 공개 메소드

Work from the middle back to the end to determine the path.
public diff_path2 ( $v_map, $text1, $text2 ) : {Array.>}
리턴 {Array.>}

diff_prettyHtml() 공개 메소드

Convert a diff array into a pretty HTML report.
public diff_prettyHtml ( $diffs ) : {string}
리턴 {string}

diff_text1() 공개 메소드

Compute and return the source text (all equalities and deletions).
public diff_text1 ( $diffs ) : {string}
리턴 {string}

diff_text2() 공개 메소드

Compute and return the destination text (all equalities and insertions).
public diff_text2 ( $diffs ) : {string}
리턴 {string}

diff_toDelta() 공개 메소드

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 diff_toDelta ( $diffs ) : {string}
리턴 {string}

diff_xIndex() 공개 메소드

e.g. 'The cat' vs 'The big cat', 1->1, 5->8
public diff_xIndex ( $diffs, $loc ) : {number}
리턴 {number}

match_alphabet() 공개 메소드

Initialise the alphabet for the Bitap algorithm.
public match_alphabet ( $pattern ) : {Object}
리턴 {Object}

match_bitap() 공개 메소드

Locate the best instance of 'pattern' in 'text' near 'loc' using the Bitap algorithm.
public match_bitap ( $text, $pattern, $loc ) : {number}
리턴 {number}

match_bitapScore() 공개 메소드

Accesses loc and pattern through being a closure.
public match_bitapScore ( $e, $x, $pattern, $loc ) : {number}
리턴 {number}

match_main() 공개 메소드

Locate the best instance of 'pattern' in 'text' near 'loc'.
public match_main ( $text, $pattern, $loc ) : {number}
리턴 {number}

patch_addContext() 공개 메소드

Increase the context until it is unique, but don't let the pattern expand beyond Match_MaxBits.
public patch_addContext ( $patch, $text )

patch_addPadding() 공개 메소드

Intended to be called only from within patch_apply.
public patch_addPadding ( &$patches ) : {string}
리턴 {string}

patch_apply() 공개 메소드

Merge a set of patches onto the text. Return a patched text, as well as a list of true/false values indicating which patches were applied.
public patch_apply ( $patches, $text ) : {Array.>}
리턴 {Array.>}

patch_deepCopy() 공개 메소드

Given an array of patches, return another array that is identical.
public patch_deepCopy ( $patches ) : {Array.}
리턴 {Array.}

patch_fromText() 공개 메소드

Parse a textual representation of patches and return a list of patch objects.
public patch_fromText ( $textline ) : {Array.}
리턴 {Array.}

patch_make() 공개 메소드

Use diffs if provided, otherwise compute it ourselves. There are four ways to call this function, depending on what data is available to the caller: Method 1: a = text1, b = text2 Method 2: a = diffs Method 3 (optimal): a = text1, b = diffs Method 4 (deprecated, use method 3): a = text1, b = text2, c = diffs
public patch_make ( $a, $opt_b = null, $opt_c = null ) : {Array.}
리턴 {Array.}

patch_splitMax() 공개 메소드

Look through the patches and break up any which are longer than the maximum limit of the match algorithm.
public patch_splitMax ( &$patches )

patch_toText() 공개 메소드

Take a list of patches and return a textual representation.
public patch_toText ( $patches ) : {string}
리턴 {string}

프로퍼티 상세

$Diff_DualThreshold 공개적으로 프로퍼티

Double-ending is twice as fast, but less accurate.
public $Diff_DualThreshold

$Diff_EditCost 공개적으로 프로퍼티

Cost of an empty edit operation in terms of edit characters.
public $Diff_EditCost

$Diff_Timeout 공개적으로 프로퍼티

Number of seconds to map a diff before giving up (0 for infinity).
public $Diff_Timeout

$Match_Distance 공개적으로 프로퍼티

1.0 to the score (0.0 is a perfect match).
public $Match_Distance

$Match_Threshold 공개적으로 프로퍼티

At what point is no match declared (0.0 = perfection, 1.0 = very loose).
public $Match_Threshold

$Patch_DeleteThreshold 공개적으로 프로퍼티

end points of a delete need to match.
public $Patch_DeleteThreshold

$Patch_Margin 공개적으로 프로퍼티

Chunk size for context length.
public $Patch_Margin