 
   var m = false;
   if let pl = lookupPattern(letter: lowercased(letter: tr)) {
-    m = matchPattern(table: pl, point: point)
+    m = matchPattern(dlist: pl, point: point)
   }
 
   if (tr == "I") { return ch == tr ? !m : m }

func needsCorrection(letter : Character) -> Bool {
  return needsCorrectionAux(c: letter, point: 0);
}

      s = setCharAt(s: s, n: i, c: x);
      i -= 1;
      space = false;
    } else {
      if !space { i -= 1; space = true; }
    }
    index -= 1;
  }
  return s;
}

let contextSize = 10;

func matchPattern(dlist : [String: Int], point : Int) -> Bool {
  var rank = dlist.count * 2;
  let s = getContext(size: contextSize, point: point);
  var (start, end, _len) = (0, 0, s.characters.count);

  while start <= contextSize {
    end = contextSize + 1;
    while end <= _len {
      let s = substring(x: start, y: end, s: s);
      if let r = dlist[s] { if abs(r) < abs(rank) { rank = r; } }
      end += 1;
    }
    start += 1;
  }
  return rank > 0;
}

func needsCorrectionAux(c : Character, point : Int) -> Bool {
