brentonashworth / clj-diff Goto Github PK
View Code? Open in Web Editor NEWDiff for Clojure Sequences
License: Eclipse Public License 1.0
Diff for Clojure Sequences
License: Eclipse Public License 1.0
Unless I am mistaken, the Shortest Edit Script function (ses
) is not linear in the length of the input. Instead it uses quadratic space for its (mis-named) fp
map, in the worst case.
By using the divide-and-conquer idea from Hirschberg, the original Myers algorithm uses linear space both for computing the edit distance D, and for computing the Shortest Edit Script, and this is also what Wu et al. claim is possible with their improved O(NP)-time algorithm.
Tests to reproduce and a possible fix attached to PR #8
That kind of call (strings of 1 to 3 chars long) fail:
(levenshtein-distance "a" "abc")
with such a stack.
Wrong number of args (0) passed to: core$max
[Thrown class clojure.lang.ArityException]
Restarts:
0: [QUIT] Quit to the SLIME top level
Backtrace:
0: clojure.lang.AFn.throwArity(AFn.java:437)
1: clojure.lang.RestFn.invoke(RestFn.java:399)
2: clojure.lang.AFn.applyToHelper(AFn.java:159)
3: clojure.lang.RestFn.applyTo(RestFn.java:132)
4: clojure.core$apply.invoke(core.clj:600)
5: clj_diff.core$levenshtein_distance.invoke(core.clj:98)
6: clj_diff.core$levenshtein_distance.invoke(core.clj:91)
7: levenshtein1.core$eval1946.invoke(NO_SOURCE_FILE:1)
8: clojure.lang.Compiler.eval(Compiler.java:6465)
9: clojure.lang.Compiler.eval(Compiler.java:6431)
10: clojure.core$eval.invoke(core.clj:2795)
11: swank.commands.basic$eval_region.invoke(basic.clj:47)
12: swank.commands.basic$eval_region.invoke(basic.clj:37)
13: swank.commands.basic$eval768$interactive_eval__769.invoke(basic.clj:66)
14: clojure.lang.Var.invoke(Var.java:401)
15: levenshtein1.core$eval1944.invoke(NO_SOURCE_FILE)
16: clojure.lang.Compiler.eval(Compiler.java:6465)
17: clojure.lang.Compiler.eval(Compiler.java:6431)
18: clojure.core$eval.invoke(core.clj:2795)
19: swank.core$eval_in_emacs_package.invoke(core.clj:92)
20: swank.core$eval_for_emacs.invoke(core.clj:239)
21: clojure.lang.Var.invoke(Var.java:409)
22: clojure.lang.AFn.applyToHelper(AFn.java:167)
23: clojure.lang.Var.applyTo(Var.java:518)
24: clojure.core$apply.invoke(core.clj:600)
25: swank.core$eval_from_control.invoke(core.clj:99)
26: swank.core$spawn_worker_thread$fn__501$fn__502.invoke(core.clj:298)
27: clojure.lang.AFn.applyToHelper(AFn.java:159)
28: clojure.lang.AFn.applyTo(AFn.java:151)
29: clojure.core$apply.invoke(core.clj:600)
30: swank.core$spawn_worker_thread$fn__501.doInvoke(core.clj:294)
31: clojure.lang.RestFn.invoke(RestFn.java:397)
32: clojure.lang.AFn.run(AFn.java:24)
33: java.lang.Thread.run(Thread.java:636)
I'm sorry but I could not dig further into the code to find an explanation.
(diff ...) works well, (edit-distance ...) too, it's just (levenshtein-distance...).
Notice: the error was reproducible on a Windows and Linux installation, thus not depending on a single weird installation...
Hi Brenton,
How do you feel about making a pre-1.0.0 non-snapshot release? Are there any issues that would make this inappropriate for production use as is?
Alex
A declarative, efficient, and flexible JavaScript library for building user interfaces.
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ššš
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ā¤ļø Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.