| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
A translation of Google's public-domain diff_match_patch code into pure Elixir.
For information about the original Google project and its application, see that repository's wiki pages.
References from the Google project:
Prior art on the BEAM:
If available in Hex, the package can be installed by adding diff_match_patch to your list of dependencies in mix.exs:
def deps do
[
{:diff_match_patch, "~> 0.2.0"}
]
endDocumentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/cursor.
loc = Dmp.Match.main(
"I am the very model of a modern major general.",
" that berry ",
5,
match_threshold: 0.7)
The value of loc is 4, finding the closest match at the string starting " the very". If no close match is found, the loc returned is -1.
diffs = Dmp.Diff.main(
"The quick brown fox jumps over the lazy dog.",
"That quick brown fox jumped over a lazy dog.")
patches1 = Dmp.Patch.make(
"The quick brown fox jumps over the lazy dog.", diffs)
patches2 = Dmp.Patch.make(
"The quick brown fox jumps over the lazy dog.",
"That quick brown fox jumped over a lazy dog.")
{new_text, matched} = Patch.apply(patches, "The quick red rabbit jumps over the tired tiger.")
IO.puts(new_text)
The new_text prints out as "That quick red rabbit jumped over a tired tiger." The matched value is a list of booleans, showing whether the results of whether matches were made between the (expanded) list of patches and the third text.
| Back | FazBrowse Home | New Git URL |