private static Tree generateSubTree(HashMap<Integer,Pair<IndexedWord,List<Integer>>> dependencies,int root){
  List<Integer> children=dependencies.get(root).second;
  IndexedWord tw=dependencies.get(root).first;
  Tree tree=new LabeledScoredTreeNode(tw);
  boolean addedHead=children.isEmpty();
  List<Integer> sortedChildren=CollectionUtils.sorted(children);
  for (  Integer c : sortedChildren) {
    if (c > root && !addedHead) {
      Tree child=new LabeledScoredTreeNode(tw);
      tree.addChild(child);
      addedHead=true;
    }
    Tree child=generateSubTree(dependencies,c);
    tree.addChild(child);
  }
  if (!addedHead) {
    Tree child=new LabeledScoredTreeNode(tw);
    tree.addChild(child);
  }
  return tree;
}

private static Tree generateSubTree ( HashMap < Integer , Pair < IndexedWord , List < Integer > > > dependencies , int root ) { List < Integer > children = dependencies . get ( root ) . second ; IndexedWord tw = dependencies . get ( root ) . first ; Tree tree = new LabeledScoredTreeNode ( tw ) ; boolean addedHead = children . isEmpty ( ) ; List < Integer > sortedChildren = CollectionUtils . sorted ( children ) ; for ( Integer c : sortedChildren ) { if ( c > root && ! addedHead ) { Tree child = new LabeledScoredTreeNode ( tw ) ; tree . addChild ( child ) ; addedHead = true ; } Tree child = generateSubTree ( dependencies , c ) ; tree . addChild ( child ) ; } if ( ! addedHead ) { Tree child = new LabeledScoredTreeNode ( tw ) ; tree . addChild ( child ) ; } return tree ; }
recursively generates a shallow constituent tree rooted at root .
