[gnome-maps] socialPlaceMatcher: Compensate for JS string indecies starting at 0



commit 080ce82907af3483f8d139c5b83af53e04258e3d
Author: Marcus Lundblad <ml update uu se>
Date:   Wed Nov 8 22:20:16 2017 +0100

    socialPlaceMatcher: Compensate for JS string indecies starting at 0
    
    The pseudo code for the iterative Levenstein implementation on
    Wikipedia assumes 1-indexed input strings. To minimize the impact
    just offset the indecies in the comparison statement using
    values from the strings.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=782861

 src/socialPlaceMatcher.js |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/src/socialPlaceMatcher.js b/src/socialPlaceMatcher.js
index c464fe6..2c8c4e9 100644
--- a/src/socialPlaceMatcher.js
+++ b/src/socialPlaceMatcher.js
@@ -46,7 +46,7 @@ function _getLevenshteinDistance(a, b) {
 
     for (j = 1; j <= b.length; j++)
         for (i = 1; i <= a.length; i++)
-            if (a[i] === b[j])
+            if (a[i - 1] === b[j - 1])
                 d[i][j] = d[i-1][j-1];
             else
                 d[i][j] = Math.min(d[i-1][j] + 1,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]