View Source Dmp.DebugUtils (diff_match_patch v0.1.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 the 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(pattern, s)

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

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

examples

Examples

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

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

View Source

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

  • d - Error level for the bitarray.
  • start - Lowest index that has been calculated.
  • best_loc - Index in the text where the best match has been found.

examples

Examples

iex> DebugUtils.debug_rd("abc", "add", 0, %{1 => 5, 2 => 7, -1 => 3}, 1, 2)
[
  "rd_j^0     pattern: 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"
]