View Source Dmp.DebugUtils (diff_match_patch v0.2.0)

Utilities for debugging bitarrays.

Link to this section Summary

Functions

Returns a list of "codepoints" (single-character strings) showing the base-2 value of value.

Formats an alphabet bitarray into a list of lines, showing binary values.

Formats the rd bitarray into a list of lines, showing binary values.

Link to this section Functions

Link to this function

bitmap_to_list(value, padding \\ 0)

View Source
@spec bitmap_to_list(non_neg_integer(), non_neg_integer()) :: [String.t()]

Returns a list of "codepoints" (single-character strings) showing the base-2 value of value.

A minimum of padding elements are returned.

Link to this function

debug_alphabet(s, pattern)

View Source
@spec debug_alphabet(Dmp.Match.alpha(), String.t()) :: [String.t()]

Formats an alphabet bitarray into a list of lines, showing binary values.

  • s - The alphabet as returned by Dmp.Match.alphabet/1.
  • pattern - The pattern that is associated with the alphabet.

examples

Examples

iex> DebugUtils.debug_alphabet(%{?a => 5, ?b => 2}, "aba")
[
  "alphabet: a b a",
  "    a  5: 1 0 1",
  "    b  2: 0 1 0"
]
Link to this function

debug_rd(rd, text, pattern, d, start \\ 0, best_loc \\ -1)

View Source

Formats the rd bitarray into a list of lines, showing binary values.

  • rd - The bitarrary.
  • text - The text associated with rd.
  • pattern - The pattern associated with rd.
  • d - The error level.
  • start - The lowest index that has been calculated. Lines below this index will be marked with an asterisk.
  • best_loc - The index in the text where the best match has been found. The line at this index will be marked with an "@"-sign.

examples

Examples

iex> DebugUtils.debug_rd(%{1 => 5, 2 => 7, -1 => 3}, "abc", "add", 0, 1, 2)
[
  "  rd_j^0: a d d",
  " 0* _  0: 0 0 0",
  " 1  a  5: 1 0 1",
  " 2  b  7: 1 1 1",
  " 3@ c  0: 0 0 0",
  " 4  _  0: 0 0 0"
]