private boolean backtrackForSwapWithPrevious(Featurizable<IString,String> f){
  if (f.prior == null)   return false;
  if (fStart(f.prior) < fStart(f))   return false;
  int indexRightCurrentPhrase=fEnd(f) + 1;
  int indexLeftPreviousPhrase=fStart(f.prior) - 1;
  if (indexLeftPreviousPhrase + 1 == indexRightCurrentPhrase)   return true;
  CoverageSet fCoverage=f.derivation.sourceCoverage;
  for (int i=indexRightCurrentPhrase; i <= indexLeftPreviousPhrase; ++i) {
    if (!fCoverage.get(i))     return false;
  }
  Featurizable<IString,String> tmp_f=f.prior;
  tmpCoverage.clear();
  boolean foundAdjPhrase=false;
  while (true) {
    if (fStart(tmp_f) == indexRightCurrentPhrase)     foundAdjPhrase=true;
    int fStart=fStart(tmp_f);
    int fEnd=fEnd(tmp_f);
    tmpCoverage.set(fStart,fEnd + 1);
    if (foundAdjPhrase && contiguous(tmpCoverage))     break;
    if (fEnd < indexRightCurrentPhrase)     return false;
    tmp_f=tmp_f.prior;
    if (tmp_f == null)     return false;
  }
  return true;
}

private boolean backtrackForSwapWithPrevious ( Featurizable < IString , String > f ) { if ( f . prior == null ) return false ; if ( fStart ( f . prior ) < fStart ( f ) ) return false ; int indexRightCurrentPhrase = fEnd ( f ) + 1 ; int indexLeftPreviousPhrase = fStart ( f . prior ) - 1 ; if ( indexLeftPreviousPhrase + 1 == indexRightCurrentPhrase ) return true ; CoverageSet fCoverage = f . derivation . sourceCoverage ; for ( int i = indexRightCurrentPhrase ; i <= indexLeftPreviousPhrase ; ++ i ) { if ( ! fCoverage . get ( i ) ) return false ; } Featurizable < IString , String > tmp_f = f . prior ; tmpCoverage . clear ( ) ; boolean foundAdjPhrase = false ; while ( true ) { if ( fStart ( tmp_f ) == indexRightCurrentPhrase ) foundAdjPhrase = true ; int fStart = fStart ( tmp_f ) ; int fEnd = fEnd ( tmp_f ) ; tmpCoverage . set ( fStart , fEnd + 1 ) ; if ( foundAdjPhrase && contiguous ( tmpCoverage ) ) break ; if ( fEnd < indexRightCurrentPhrase ) return false ; tmp_f = tmp_f . prior ; if ( tmp_f == null ) return false ; } return true ; }
returns true if current block is swap with any contiguous set of previous blocks .
