@@ -50,7 +50,7 @@ to assist natural language translation based on translation memory.
5050
5151Let’s take a simple example of finding minimum edit distance between
5252strings ` ME ` and ` MY ` . Intuitively you already know that minimum edit distance
53- here is ` 1 ` operation and this operation. And it is a replacing ` E ` with ` Y ` . But
53+ here is ` 1 ` operation and this operation. And it is replacing ` E ` with ` Y ` . But
5454let’s try to formalize it in a form of the algorithm in order to be able to
5555do more complex examples like transforming ` Saturday ` into ` Sunday ` .
5656
@@ -75,12 +75,12 @@ to transform an empty string to `MY`. And it is by inserting `Y` and `M`.
7575- Cell ` (1:1) ` contains number 0. It means that it costs nothing
7676to transform ` M ` into ` M ` .
7777- Cell ` (1:2) ` contains red number 1. It means that we need 1 operation
78- to transform ` ME ` to ` M ` . And it is be deleting ` E ` .
78+ to transform ` ME ` to ` M ` . And it is by deleting ` E ` .
7979- And so on...
8080
8181This looks easy for such small matrix as ours (it is only ` 3x3 ` ). But here you
8282may find basic concepts that may be applied to calculate all those numbers for
83- bigger matrices (let’s say ` 9x7 ` one, for ` Saturday → Sunday ` transformation).
83+ bigger matrices (let’s say a ` 9x7 ` matrix for ` Saturday → Sunday ` transformation).
8484
8585According to the formula you only need three adjacent cells ` (i-1:j) ` , ` (i-1:j-1) ` , and ` (i:j-1) ` to
8686calculate the number for current cell ` (i:j) ` . All we need to do is to find the
@@ -97,13 +97,13 @@ Let's draw a decision graph for this problem.
9797
9898You may see a number of overlapping sub-problems on the picture that are marked
9999with red. Also there is no way to reduce the number of operations and make it
100- less then a minimum of those three adjacent cells from the formula.
100+ less than a minimum of those three adjacent cells from the formula.
101101
102102Also you may notice that each cell number in the matrix is being calculated
103103based on previous ones. Thus the tabulation technique (filling the cache in
104104bottom-up direction) is being applied here.
105105
106- Applying this principles further we may solve more complicated cases like
106+ Applying this principle further we may solve more complicated cases like
107107with ` Saturday → Sunday ` transformation.
108108
109109![ Levenshtein distance] ( https://cdn-images-1.medium.com/max/1600/1*fPEHiImYLKxSTUhrGbYq3g.jpeg )
0 commit comments