public Tree<String> extractBestMaxRuleParse1(int start,int end,int state,List<String> sentence){
  int cState=maxcChild[start][end][state];
  if (cState == -1) {
    return extractBestMaxRuleParse2(start,end,state,sentence);
  }
 else {
    List<Tree<String>> child=new ArrayList<Tree<String>>();
    child.add(extractBestMaxRuleParse2(start,end,cState,sentence));
    String stateStr=(String)tagNumberer.object(state);
    if (stateStr.endsWith("^g"))     stateStr=stateStr.substring(0,stateStr.length() - 2);
    totalUsedUnaries++;
    int intermediateNode=grammar.getUnaryIntermediate((short)state,(short)cState);
    if (intermediateNode > 0) {
      List<Tree<String>> restoredChild=new ArrayList<Tree<String>>();
      nTimesRestoredUnaries++;
      String stateStr2=(String)tagNumberer.object(intermediateNode);
      if (stateStr2.endsWith("^g"))       stateStr2=stateStr2.substring(0,stateStr2.length() - 2);
      restoredChild.add(new Tree<String>(stateStr2,child));
      return new Tree<String>(stateStr,restoredChild);
    }
    return new Tree<String>(stateStr,child);
  }
}

public Tree < String > extractBestMaxRuleParse1 ( int start , int end , int state , List < String > sentence ) { int cState = maxcChild [ start ] [ end ] [ state ] ; if ( cState == - 1 ) { return extractBestMaxRuleParse2 ( start , end , state , sentence ) ; } else { List < Tree < String > > child = new ArrayList < Tree < String > > ( ) ; child . add ( extractBestMaxRuleParse2 ( start , end , cState , sentence ) ) ; String stateStr = ( String ) tagNumberer . object ( state ) ; if ( stateStr . endsWith ( "^g" ) ) stateStr = stateStr . substring ( 0 , stateStr . length ( ) - 2 ) ; totalUsedUnaries ++ ; int intermediateNode = grammar . getUnaryIntermediate ( ( short ) state , ( short ) cState ) ; if ( intermediateNode > 0 ) { List < Tree < String > > restoredChild = new ArrayList < Tree < String > > ( ) ; nTimesRestoredUnaries ++ ; String stateStr2 = ( String ) tagNumberer . object ( intermediateNode ) ; if ( stateStr2 . endsWith ( "^g" ) ) stateStr2 = stateStr2 . substring ( 0 , stateStr2 . length ( ) - 2 ) ; restoredChild . add ( new Tree < String > ( stateStr2 , child ) ) ; return new Tree < String > ( stateStr , restoredChild ) ; } return new Tree < String > ( stateStr , child ) ; } }
returns the best parse for state " state " , potentially starting with a unary rule
