Giter Site home page Giter Site logo

myers-diff's Issues

printTrace

thanks your implementation helped me to understand the algorithm。

func printTrace(trace []map[int]int) {

not all k in [-d, d] will save in trace. if k not in trace x := v[k] x will be zero as default.

may be this is the better

func printTrace(trace []map[int]int) {
	for d := 0; d < len(trace); d++ {
		fmt.Printf("d = %d:\n", d)
		v := trace[d]
		for k, x := range v {
			y := x - k
			fmt.Printf("   k = %2d: (%d, %d)\n", k, x, y)
		}
	}
}

回溯时循环条件好像有点问题

https://github.com/fate-lovely/myers-diff/blob/4613bf7fbf0ba327d5e9069d364e78b721cca17e/main.go#L157
我使用
A B C D E

A B D E测试的时候,结果是
-A B C,定位到错误应该是在回溯的时候,这里d==0的时候也应该考虑进去,如果两个文本前面内容相同,需要在d==0的时候执行添加MOV的操作。在https://github.com/pkg/diff/blob/7e42a82532c282d39d727ace02bfdef801c6db2c/myers.go#L71 这个实现里面就有考虑d==0的情况

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.