Difflib

A set of helpers for computing deltas between objects.

Difflib is a partial port of python 3's difflib.

The port is meant to closely resemble the code, docs, and tests from the python implementation for easy reference between the two.

Status of the classes and functions to be ported from python

Completed:

Not Started:

Installation

The package can be installed by adding difflib to your list of dependencies in mix.exs:

def deps do
  [
    {:difflib, "~> 0.1.0"}
  ]
end

Basic Usage

iex> SequenceMatcher.get_close_matches("appel", ["ape", "apple", "peach", "puppy"])
["apple", "ape"]

iex> a = "qabxcd"
iex> b = "abycdf"
iex> SequenceMatcher.get_opcodes(a, b)
[
  {:delete, 0, 1, 0, 0},
  {:equal, 1, 3, 0, 2},
  {:replace, 3, 4, 2, 3},
  {:equal, 4, 6, 3, 5},
  {:insert, 6, 6, 5, 6}
]

iex> a = "abcd"
iex> b = "bcde"
iex> SequenceMatcher.ratio(a, b)
0.75

Documentation

Complete documentation can be found at https://hexdocs.pm/difflib

Source

Code can be found at https://github.com/gschro/difflib