public static String normalize ( final String token ) { String normalizedToken = "" ; char currentCharacter ; int prevCharType = - 1 ; char charType = ' ' ; boolean addedStar = false ; for ( int i = 0 ; i < token . length ( ) ; i ++ ) { currentCharacter = token . charAt ( i ) ; if ( currentCharacter >= ' ' && currentCharacter <= ' ' ) { charType = ' ' ; } else if ( currentCharacter >= ' ' && currentCharacter <= ' ' ) { charType = ' ' ; } else if ( currentCharacter >= ' ' && currentCharacter <= ' ' ) { charType = ' ' ; } else { charType = currentCharacter ; } if ( charType == prevCharType ) { if ( ! addedStar ) { normalizedToken += "*" ; addedStar = true ; } } else { addedStar = false ; normalizedToken += charType ; } prevCharType = charType ; } return normalizedToken ; }
Normalize upper case lower case digits and duplicate characters .