public String mutateLangModel(final String input){
  if (input.length() == 0) {
    return input;
  }
  int startPoint=(int)(Randomness.nextDouble() * (input.length()));
  int remainingLength=(int)Math.round(Randomness.nextDouble() * (input.length() - startPoint));
  if (remainingLength == 0) {
    return input;
  }
  String output=input.substring(0,startPoint);
  String replacementChunk=generateRandomStringFromModelWithExactLength(remainingLength,"" + input.charAt(startPoint));
  output+=replacementChunk;
  output+=input.substring(startPoint + remainingLength,input.length());
  return output;
}

public String mutateLangModel ( final String input ) { if ( input . length ( ) == 0 ) { return input ; } int startPoint = ( int ) ( Randomness . nextDouble ( ) * ( input . length ( ) ) ) ; int remainingLength = ( int ) Math . round ( Randomness . nextDouble ( ) * ( input . length ( ) - startPoint ) ) ; if ( remainingLength == 0 ) { return input ; } String output = input . substring ( 0 , startPoint ) ; String replacementChunk = generateRandomStringFromModelWithExactLength ( remainingLength , "" + input . charAt ( startPoint ) ) ; output += replacementChunk ; output += input . substring ( startPoint + remainingLength , input . length ( ) ) ; return output ; }
produce a new string similar to input . selects a random substring of the string and for each character in that substring : gets the character preceeding it gets a character the language model predicts to follow that prefix replaces the character with the predicted character
