Warning: session_start(): open(/var/lib/php/sessions/sess_4vqkrmkrrhd14hoe1ob80v6egs, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
// Calculates the fuzzy match of needle in haystack,
// using a modified version of the Levenshtein distance algorithm.
// ported from: http://ginstrom.com/scribbles/2007/12/01/fuzzy-substring-matching-with-levenshtein-distance-in-python/
static int levenSubstringIC(S needle, S haystack) {
int m = l(needle), n = l(haystack);
// base cases
if (m == 1)
ret cic(haystack, needle) ? 1 : 0;
if (m == 0)
ret m;
int[] row1 = new int[n+1];
for (int i = 0; i <= m; i++) {
int row2 = [i+1]; // ?
for (int j = 0; j <= n; j++) {
int cost = neqic(needle.charAt(i), haystack.charAt(j));
row2.add(min(row1[j+1]+1, # deletion
row2[j]+1, #insertion
row1[j]+cost) #substitution
);
}
row1 = row2;
}
ret minInt(row1);
}