private String diff_wordsToCharsMunge(String text,List<String> lineArray,Map<String,Integer> lineHash){
  int lineStart=0;
  int lineEnd=-1;
  String line;
  StringBuilder chars=new StringBuilder();
  while (lineEnd < text.length() - 1) {
    String patternStr="[. :;\\[\\]\\{\\}\\(\\)\\+!?\\-]";
    Pattern pattern=Pattern.compile(patternStr);
    Matcher matcher=pattern.matcher(text);
    matcher.region(lineStart,text.length());
    if (matcher.find()) {
      lineEnd=matcher.start();
    }
 else     lineEnd=-1;
    if (lineEnd == -1) {
      lineEnd=text.length() - 1;
    }
    line=text.substring(lineStart,lineEnd + 1);
    lineStart=lineEnd + 1;
    if (lineHash.containsKey(line)) {
      chars.append(String.valueOf((char)(int)lineHash.get(line)));
    }
 else {
      lineArray.add(line);
      lineHash.put(line,lineArray.size() - 1);
      chars.append(String.valueOf((char)(lineArray.size() - 1)));
    }
  }
  return chars.toString();
}

private String diff_wordsToCharsMunge ( String text , List < String > lineArray , Map < String , Integer > lineHash ) { int lineStart = 0 ; int lineEnd = - 1 ; String line ; StringBuilder chars = new StringBuilder ( ) ; while ( lineEnd < text . length ( ) - 1 ) { String patternStr = "[. :;\\[\\]\\{\\}\\(\\)\\+!?\\-]" ; Pattern pattern = Pattern . compile ( patternStr ) ; Matcher matcher = pattern . matcher ( text ) ; matcher . region ( lineStart , text . length ( ) ) ; if ( matcher . find ( ) ) { lineEnd = matcher . start ( ) ; } else lineEnd = - 1 ; if ( lineEnd == - 1 ) { lineEnd = text . length ( ) - 1 ; } line = text . substring ( lineStart , lineEnd + 1 ) ; lineStart = lineEnd + 1 ; if ( lineHash . containsKey ( line ) ) { chars . append ( String . valueOf ( ( char ) ( int ) lineHash . get ( line ) ) ) ; } else { lineArray . add ( line ) ; lineHash . put ( line , lineArray . size ( ) - 1 ) ; chars . append ( String . valueOf ( ( char ) ( lineArray . size ( ) - 1 ) ) ) ; } } return chars . toString ( ) ; }
split a text into a list of strings . reduce the texts to a string of hashes where each unicode character represents one word .
