19 namespace SpellChecker.Net.Search.Spell
28 internal int[][][] cache =
new int[30][][];
36 sa = target.ToCharArray();
44 public int GetDistance(System.String other)
49 char[] ta = other.ToCharArray();
60 if (m >= cache.Length)
64 else if (cache[m] != null)
70 d = cache[m] = Form(n, m);
74 for (
int i = 1; i <= n; i++)
80 for (
int j = 1; j <= m; j++)
86 int cost = s_i == t_j ? 0 : 1;
87 d[i][j] = Min3(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + cost);
97 private static int[][] Form(
int n,
int m)
99 int[][] d =
new int[n + 1][];
100 for (
int i = 0; i < n + 1; i++)
102 d[i] =
new int[m + 1];
106 for (
int i = 0; i <= n; i++)
110 for (
int j = 0; j <= m; j++)
121 private static int Min3(
int a,
int b,
int c)