protected List<String> edits(String word){
  List<String> candidates=new ArrayList<String>();
  for (int i=0; i < word.length(); i++) {
    candidates.add(word.substring(0,i) + word.substring(i + 1));
    for (char c='a'; c <= 'z'; c++) {
      candidates.add(word.substring(0,i) + c + word.substring(i + 1));
      candidates.add(word.substring(0,i) + c + word.substring(i));
    }
  }
  for (char c='a'; c <= 'z'; c++) {
    candidates.add(word + c);
  }
  for (int i=0; i < word.length() - 1; i++) {
    candidates.add(word.substring(0,i) + word.substring(i + 1,i + 2) + word.substring(i,i + 1)+ word.substring(i + 2));
  }
  return candidates;
}

protected List < String > edits ( String word ) { List < String > candidates = new ArrayList < String > ( ) ; for ( int i = 0 ; i < word . length ( ) ; i ++ ) { candidates . add ( word . substring ( 0 , i ) + word . substring ( i + 1 ) ) ; for ( char c = 'a' ; c <= 'z' ; c ++ ) { candidates . add ( word . substring ( 0 , i ) + c + word . substring ( i + 1 ) ) ; candidates . add ( word . substring ( 0 , i ) + c + word . substring ( i ) ) ; } } for ( char c = 'a' ; c <= 'z' ; c ++ ) { candidates . add ( word + c ) ; } for ( int i = 0 ; i < word . length ( ) - 1 ; i ++ ) { candidates . add ( word . substring ( 0 , i ) + word . substring ( i + 1 , i + 2 ) + word . substring ( i , i + 1 ) + word . substring ( i + 2 ) ) ; } return candidates ; }
get a list for all possible variants of the given word containing an insertion , deletion , replacement or transposition .
