All Projects → cubicdaiya → gonp

cubicdaiya / gonp

Licence: MIT license
diff algorithm in Go

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to gonp

Webdiff
Two-column web-based git difftool
Stars: ✭ 208 (+395.24%)
Mutual labels:  diff
Diff So Fancy
Good-lookin' diffs. Actually… nah… The best-lookin' diffs. 🎉
Stars: ✭ 14,806 (+35152.38%)
Mutual labels:  diff
graphql-schema-diff
📄🔄📄 Returns the diff of two GraphQL schemas. Detects dangerous and breaking changes.
Stars: ✭ 54 (+28.57%)
Mutual labels:  diff
Openapi Diff
Utility for comparing two OpenAPI specifications.
Stars: ✭ 208 (+395.24%)
Mutual labels:  diff
Awesome Website Change Monitoring
A curated list of awesome tools for website diffing and change monitoring.
Stars: ✭ 224 (+433.33%)
Mutual labels:  diff
Rxdatasources
UITableView and UICollectionView Data Sources for RxSwift (sections, animated updates, editing ...)
Stars: ✭ 2,784 (+6528.57%)
Mutual labels:  diff
Difference.rs
Rust text diffing and assertion library
Stars: ✭ 206 (+390.48%)
Mutual labels:  diff
knowledge-graph-change-language
Tools for working with KGCL
Stars: ✭ 14 (-66.67%)
Mutual labels:  diff
Listdiff
Swift port of IGListKit's IGListDiff
Stars: ✭ 225 (+435.71%)
Mutual labels:  diff
vscode-diff
Compare two folders in Visual Studio Code
Stars: ✭ 66 (+57.14%)
Mutual labels:  diff
Elm Package
Command line tool to share Elm libraries
Stars: ✭ 214 (+409.52%)
Mutual labels:  diff
Ex audit
Ecto auditing library that transparently tracks changes and can revert them.
Stars: ✭ 214 (+409.52%)
Mutual labels:  diff
git-tui
Collection of human friendly terminal interface for git.
Stars: ✭ 95 (+126.19%)
Mutual labels:  diff
Pytest Clarity
A plugin to improve the output of pytest with colourful unified diffs
Stars: ✭ 209 (+397.62%)
Mutual labels:  diff
diffy
Tools for finding and manipulating differences between files
Stars: ✭ 47 (+11.9%)
Mutual labels:  diff
Swiftlcs
Swift implementation of the longest common subsequence (LCS) algorithm.
Stars: ✭ 207 (+392.86%)
Mutual labels:  diff
Dsladapter
🔥 Kotlin时代的Adapter, Dsl 的形式使用 RecyclerView.Adapter, 支持折叠展开, 树结构,悬停,情感图状态切换, 加载更多, 多类型Item,侧滑菜单等
Stars: ✭ 231 (+450%)
Mutual labels:  diff
haoide-vscode
haoide-vscode is a vscode extension for salesforce development, which is used to replace haoide
Stars: ✭ 22 (-47.62%)
Mutual labels:  diff
ExtDiff
Compare documents using MS Word from the command line.
Stars: ✭ 100 (+138.1%)
Mutual labels:  diff
ttdo
Extend tinytest with diffobj
Stars: ✭ 21 (-50%)
Mutual labels:  diff

workflow status

gonp

gonp is a diff algorithm implementation in Go.

Algorithm

The algorithm gonp uses is based on "An O(NP) Sequence Comparison Algorithm" by described by Sun Wu, Udi Manber and Gene Myers. An O(NP) Sequence Comparison Algorithm(following, Wu's O(NP) Algorithm) is the efficient algorithm for comparing two sequences.

Computational complexity

The computational complexity of Wu's O(NP) Algorithm is averagely O(N+PD), in the worst case, is O(NP).

Getting started

string difference

diff := gonp.New([]rune("abc"), []rune("abd"))
diff.Compose()
ed := diff.Editdistance() // ed is 2
lcs := diff.Lcs() // lcs is "ab"

ses := diff.Ses()
// ses is []SesElem{
//        {e: 'a', t: Common},
//        {e: 'b', t: Common},
//        {e: 'c', t: Delete},
//        {e: 'd', t: Add},
//        }

int slice difference

diff := gonp.New([]int{1,2,3}, []int{1,5,3})
diff.Compose()
ed := diff.Editdistance() // ed is 2
lcs := diff.Lcs() // lcs is [1,3]

ses := diff.Ses()
// ses is []SesElem{
//        {e: 1, t: Common},
//        {e: 2, t: Delete},
//        {e: 5, t: Add},
//        {e: 3, t: Common},
//        }

unified format difference

diff := gonp.New([]rune("abc"), []rune("abd"))
diff.Compose()

uniHunks := diff.UnifiedHunks()
diff.PrintUniHunks(uniHunks)
// @@ -1,3 +1,3 @@
//  a
//  b
// -c
// +d

Example

strdiff

$ make strdiff
go build -o strdiff examples/strdiff.go
$ ./strdiff abc abd
Editdistance: 2
LCS: ab
SES:
  a
  b
- c
+ d

intdiff

$ make intdiff
go build -o intdiff examples/intdiff.go
$ ./intdiff
diff [1 2 3 4 5] [1 2 9 4 5]
Editdistance: 2
LCS: [1 2 4 5]
SES:
  1
  2
- 3
+ 9
  4
  5

unistrdiff

$ make unistrdiff
go build -o unistrdiff examples/unistrdiff.go
$ ./unistrdiff abc abd
Editdistance:2
LCS:ab
Unified format difference:
@@ -1,3 +1,3 @@
 a
 b
-c
+d

uniintdiff

$ make uniintdiff
go build -o uniintdiff examples/uniintdiff.go
$ ./uniintdiff
diff [1 2 3 4 5] [1 2 9 4 5]
Editdistance: 2
LCS: [1 2 4 5]
Unified format difference:
@@ -1,5 +1,5 @@
 1
 2
-3
+9
 4
 5

unifilediff

$ make unifilediff
go build -o unifilediff examples/unifilediff.go
$ cat a.txt
a
b
c
$ cat b.txt
a
b
d
$ ./unifilediff a.txt b.txt
@@ -1,3 +1,3 @@
 a
 b
-c
+d
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].