package patience_diff

  1. Overview
  2. Docs
type elt = string
val get_matching_blocks : transform:('a -> elt) -> mine:'a array -> other:'a array -> Matching_block.t list
val matches : elt array -> elt array -> (int * int) list

matches a b returns a list of pairs (i,j) such that a.(i) = b.(j) and such that the list is strictly increasing in both its first and second coordinates. This is essentially a "unfolded" version of what get_matching_blocks returns. Instead of grouping the consecutive matching block using length this function would return all the pairs (mine_start * other_start).

val match_ratio : elt array -> elt array -> float

match_ratio ~compare a b computes the ratio defined as:

2 * len (matches a b) / (len a + len b)

It is an indication of how much alike a and b are. A ratio closer to 1.0 will indicate a number of matches close to the number of elements that can potentially match, thus is a sign that a and b are very much alike. On the other hand, a low ratio means very little match.

val get_hunks : transform:('a -> elt) -> context:int -> mine:'a array -> other:'a array -> 'a Hunk.t list

get_hunks ~transform ~context ~mine ~other will compare the arrays mine and other and produce a list of hunks. (The hunks will contain Same ranges of at most context elements.) context defaults to infinity (producing a singleton hunk list).

type 'a segment =
  1. | Same of 'a array
  2. | Different of 'a array array
type 'a merged_array = 'a segment list
val merge : elt array array -> elt merged_array
OCaml

Innovation. Community. Security.