private String[] diff_halfMatchI(String longtext,String shorttext,int i){
  String seed=longtext.substring(i,i + longtext.length() / 4);
  int j=-1;
  String best_common="";
  String best_longtext_a="", best_longtext_b="";
  String best_shorttext_a="", best_shorttext_b="";
  while ((j=shorttext.indexOf(seed,j + 1)) != -1) {
    int prefixLength=diff_commonPrefix(longtext.substring(i),shorttext.substring(j));
    int suffixLength=diff_commonSuffix(longtext.substring(0,i),shorttext.substring(0,j));
    if (best_common.length() < suffixLength + prefixLength) {
      best_common=shorttext.substring(j - suffixLength,j) + shorttext.substring(j,j + prefixLength);
      best_longtext_a=longtext.substring(0,i - suffixLength);
      best_longtext_b=longtext.substring(i + prefixLength);
      best_shorttext_a=shorttext.substring(0,j - suffixLength);
      best_shorttext_b=shorttext.substring(j + prefixLength);
    }
  }
  if (best_common.length() * 2 >= longtext.length()) {
    return new String[]{best_longtext_a,best_longtext_b,best_shorttext_a,best_shorttext_b,best_common};
  }
 else {
    return null;
  }
}

private String [ ] diff_halfMatchI ( String longtext , String shorttext , int i ) { String seed = longtext . substring ( i , i + longtext . length ( ) / 4 ) ; int j = - 1 ; String best_common = "" ; String best_longtext_a = "" , best_longtext_b = "" ; String best_shorttext_a = "" , best_shorttext_b = "" ; while ( ( j = shorttext . indexOf ( seed , j + 1 ) ) != - 1 ) { int prefixLength = diff_commonPrefix ( longtext . substring ( i ) , shorttext . substring ( j ) ) ; int suffixLength = diff_commonSuffix ( longtext . substring ( 0 , i ) , shorttext . substring ( 0 , j ) ) ; if ( best_common . length ( ) < suffixLength + prefixLength ) { best_common = shorttext . substring ( j - suffixLength , j ) + shorttext . substring ( j , j + prefixLength ) ; best_longtext_a = longtext . substring ( 0 , i - suffixLength ) ; best_longtext_b = longtext . substring ( i + prefixLength ) ; best_shorttext_a = shorttext . substring ( 0 , j - suffixLength ) ; best_shorttext_b = shorttext . substring ( j + prefixLength ) ; } } if ( best_common . length ( ) * 2 >= longtext . length ( ) ) { return new String [ ] { best_longtext_a , best_longtext_b , best_shorttext_a , best_shorttext_b , best_common } ; } else { return null ; } }
does a substring of shorttext exist within longtext such that the substring is at least half the length of longtext ?
