code: public int ed(final int i, final int j, final int wordIndex, final int candIndex) {
      int result;
      int a, b, c;
  
      if (areEqual(wordProcessed[wordIndex], candidate[candIndex])) {
        // last characters are the same
        result = hMatrix.get(i, j);
      } else if (wordIndex > 0 && candIndex > 0 && wordProcessed[wordIndex] == candidate[candIndex - 1]
          && wordProcessed[wordIndex - 1] == candidate[candIndex]) {
        // last two characters are transposed
        a = hMatrix.get(i - 1, j - 1); // transposition, e.g. ababab, ababba
        b = hMatrix.get(i + 1, j); // deletion, e.g. abab, aba
        c = hMatrix.get(i, j + 1); // insertion e.g. aba, abab
        result = 1 + min(a, b, c);
      } else {
        // otherwise
        a = hMatrix.get(i, j); // replacement, e.g. ababa, ababb
        b = hMatrix.get(i + 1, j); // deletion, e.g. ab, a
        c = hMatrix.get(i, j + 1); // insertion e.g. a, ab
        result = 1 + min(a, b, c);
      }
  
      hMatrix.set(i + 1, j + 1, result);
      return result;
    }
docs: Calculates edit distance.
  
  @param i length of first word (here: misspelled) - 1;
  @param j length of second word (here: candidate) - 1.
  @param wordIndex (TODO: javadoc?)
  @param candIndex (TODO: javadoc?)
  @return Edit distance between the two words. Remarks: See Oflazer.