Comments (10)
Update.
Playing a bit with the code, I noticed that the distance produced by edit_distance(a, b)
is a tuple of two elements, where the first is equal to the distance produced by edit_distance_backpointer(a, b)
. HTH.
from edit-distance.
Update/2.
Going on analyzing my data, I found this interesting example.
In this case:
- the
edit_distance
function returns a tuple which is(17, 12)
; - the
edit_distance_backpointer
function returns a distance value which is16
.
Here follows the dump of (almost) everything:
a = ['that', 'continuous', 'sanction', ':=', '(', 'flee', 'U', 'complain', ')', 'E', 'attendance', 'eye', '^', 'flowery', 'revelation', '^', 'ridiculous', 'destination', '<EOS>', '<EOS>', '<EOS>', '<EOS>', '<EOS>', '<EOS>', '<EOS>', '<EOS>', '<EOS>', '<EOS>', '<EOS>']
b = ['continuous', ':=', '(', 'sanction', '^', 'flee', '^', 'attendance', '<EOS>', '<EOS>', '<EOS>', '<EOS>', '<EOS>', '<EOS>', '<EOS>', '<EOS>', '<EOS>', '<EOS>', '<EOS>', '<EOS>', '<EOS>', '<EOS>', '<EOS>', '<EOS>', '<EOS>', '<EOS>', '<EOS>', '<EOS>', '<EOS>']
edit_distance(a, b) -> (17, 12)
edit_distance_backpointer(a, b) -> 16
delete T[0:1] -> P[0:0] ['that'] -> []
equal T[1:2] -> P[0:1] ['continuous'] -> ['continuous']
delete T[2:3] -> P[0:0] ['sanction'] -> []
equal T[3:4] -> P[1:2] [':='] -> [':=']
equal T[4:5] -> P[2:3] ['('] -> ['(']
insert T[4:4] -> P[3:4] [] -> ['sanction']
insert T[4:4] -> P[4:5] [] -> ['^']
equal T[5:6] -> P[5:6] ['flee'] -> ['flee']
replace T[6:7] -> P[6:7] ['U'] -> ['^']
replace T[7:8] -> P[7:8] ['complain'] -> ['attendance']
replace T[8:9] -> P[8:9] [')'] -> ['<EOS>']
replace T[9:10] -> P[9:10] ['E'] -> ['<EOS>']
replace T[10:11] -> P[10:11] ['attendance'] -> ['<EOS>']
replace T[11:12] -> P[11:12] ['eye'] -> ['<EOS>']
replace T[12:13] -> P[12:13] ['^'] -> ['<EOS>']
replace T[13:14] -> P[13:14] ['flowery'] -> ['<EOS>']
replace T[14:15] -> P[14:15] ['revelation'] -> ['<EOS>']
replace T[15:16] -> P[15:16] ['^'] -> ['<EOS>']
replace T[16:17] -> P[16:17] ['ridiculous'] -> ['<EOS>']
replace T[17:18] -> P[17:18] ['destination'] -> ['<EOS>']
equal T[18:19] -> P[18:19] ['<EOS>'] -> ['<EOS>']
equal T[19:20] -> P[19:20] ['<EOS>'] -> ['<EOS>']
equal T[20:21] -> P[20:21] ['<EOS>'] -> ['<EOS>']
equal T[21:22] -> P[21:22] ['<EOS>'] -> ['<EOS>']
equal T[22:23] -> P[22:23] ['<EOS>'] -> ['<EOS>']
equal T[23:24] -> P[23:24] ['<EOS>'] -> ['<EOS>']
equal T[24:25] -> P[24:25] ['<EOS>'] -> ['<EOS>']
equal T[25:26] -> P[25:26] ['<EOS>'] -> ['<EOS>']
equal T[26:27] -> P[26:27] ['<EOS>'] -> ['<EOS>']
equal T[27:28] -> P[27:28] ['<EOS>'] -> ['<EOS>']
equal T[28:29] -> P[28:29] ['<EOS>'] -> ['<EOS>']
from edit-distance.
Update/3.
Flipping the two sequences, everything goes fine.
from edit-distance.
Yup, your data looks really weird:). I am able to reproduce the problem and am looking into it.
from edit-distance.
Hi @petrux - I think I found the problem and fixed. Would you be able to try it out and confirm that you don't get the error anymore? Thanks very much for pointing this out too.
from edit-distance.
Sure. Shall I reinstall from pip
or checkout the code?
from edit-distance.
from edit-distance.
Checked right now installing via pip
on a python3.5
virtual environment. The behavior looks coherent: in all cases I have the tuple (16, 15)
as a result. Just to ask -- since I am not very familiar with the theoretical foundations of the edit distance -- why a tuple of values? Thanks!
from edit-distance.
Sorry, it's probably not clear anywhere. The first value is the edit distance, the second value is the number of matches. The number of matches can be useful to know too.
from edit-distance.
Cool, thanks for the explanation!
from edit-distance.
Related Issues (5)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from edit-distance.