DiffMatchPatch
public struct DiffMatchPatch
Engine for computing the difference between two strings. This is a Swift port of the Python3 version of the code found at https://github.com/google/diff-match-patch.
-
init(diffTimeout:
diffEditCost: matchThreshold: matchDistance: patchDeleteThreshold: patchMargin: matchMaxBits: ) Undocumented
Declaration
Swift
public init(diffTimeout: TimeInterval = duration(1.0, .seconds), diffEditCost: Int = 4, matchThreshold: Double = 0.5, matchDistance: Int = 1000, patchDeleteThreshold: Double = 0.5, patchMargin: Int = 4, matchMaxBits: Int = 32)
-
Number of seconds to map a diff before giving up (0 for infinity).
Declaration
Swift
public var diffTimeout: TimeInterval
-
Cost of an empty edit operation in terms of edit characters.
Declaration
Swift
public var diffEditCost: Int
-
At what point is no match declared (0.0 = perfection, 1.0 = very loose).
Declaration
Swift
public var matchThreshold: Double
-
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).
Declaration
Swift
public var matchDistance: Int
-
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 Match_Threshold controls how closely the end points of a delete need to match.
Declaration
Swift
public var patchDeleteThreshold: Double
-
Chunk size for context length.
Declaration
Swift
public var patchMargin: Int
-
Find the differences between two texts, and return it as an array of difference descriptions. Note that you are not passing in two
String
values, but rather twoSubstring
values that should be substrings representing the entire strings. The reason for this is to make the recursion a bit easier.Declaration
Swift
public func main(_ text1in: Substring, _ text2in: Substring, _ deadline1: Date? = nil) -> [Difference]
Parameters
text1in
The “old” string of the difference.
text2in
The “new” string of the difference.
deadline
Optional time when the diff should be complete by. Used internally for recursive calls. Users should set
diffTimeout
instead.Return Value
An array of the difference descriptions.