public static ArrayList<Map.Entry<String,String>> split(final String text){
  ArrayList<Map.Entry<String,String>> a=new ArrayList<>(1 + text.length() / 4);
  final StringBuilder o=new StringBuilder();
  final StringBuilder l=new StringBuilder();
  for (int i=0; i < text.length(); i++) {
    final char c=text.charAt(i);
    if (Character.isLetterOrDigit(c)) {
      o.append(c);
      l.append(Character.toLowerCase(c));
      continue;
    }
    if (o.length() > 0) {
      a.add(new AbstractMap.SimpleEntry<String,String>(l.toString(),o.toString()));
      o.setLength(0);
      l.setLength(0);
    }
  }
  if (o.length() > 0) {
    a.add(new AbstractMap.SimpleEntry<String,String>(l.toString(),o.toString()));
    o.setLength(0);
    l.setLength(0);
  }
  return a;
}

public static ArrayList < Map . Entry < String , String > > split ( final String text ) { ArrayList < Map . Entry < String , String > > a = new ArrayList < > ( 1 + text . length ( ) / 4 ) ; final StringBuilder o = new StringBuilder ( ) ; final StringBuilder l = new StringBuilder ( ) ; for ( int i = 0 ; i < text . length ( ) ; i ++ ) { final char c = text . charAt ( i ) ; if ( Character . isLetterOrDigit ( c ) ) { o . append ( c ) ; l . append ( Character . toLowerCase ( c ) ) ; continue ; } if ( o . length ( ) > 0 ) { a . add ( new AbstractMap . SimpleEntry < String , String > ( l . toString ( ) , o . toString ( ) ) ) ; o . setLength ( 0 ) ; l . setLength ( 0 ) ; } } if ( o . length ( ) > 0 ) { a . add ( new AbstractMap . SimpleEntry < String , String > ( l . toString ( ) , o . toString ( ) ) ) ; o . setLength ( 0 ) ; l . setLength ( 0 ) ; } return a ; }
split the text into word tokens . the tokens are lower - cased . to maintain the original spelling of the word without lowercasing them , the original word is attached too .
