private void dumpRec (Object node, int lvl, StringBuffer buf) { for (int i = 0; i < 3 * lvl; i++) { buf.append ("-"); } buf.append (" ").append (node).append ("\n"); for (Iterator it = getChildren (node).iterator (); it.hasNext();) { Object child = it.next (); dumpRec (child, lvl+1, buf); } }
private void dumpRec (Object node, int lvl, StringBuffer buf) { for (int i = 0; i < 3 * lvl; i++) { buf.append ("-"); } buf.append (" ").append (node).append ("\n"); for (Iterator it = getChildren (node).iterator (); it.hasNext();) { Object child = it.next (); dumpRec (child, lvl+1, buf); } }
private void dumpRec (Object node, int lvl, StringBuffer buf) { for (int i = 0; i < 3 * lvl; i++) { buf.append ("-"); } buf.append (" ").append (node).append ("\n"); for (Iterator it = getChildren (node).iterator (); it.hasNext();) { Object child = it.next (); dumpRec (child, lvl+1, buf); } }
/** Sends BP messages starting from parents to children. This version uses constant stack space. */ private void piPropagation (cc.mallet.grmm.types.Tree tree, Object root) { LinkedList openList = new LinkedList (); openList.add (root); while (!openList.isEmpty ()) { Object current = openList.removeFirst (); List children = tree.getChildren (current); for (Iterator it = children.iterator (); it.hasNext ();) { Object child = it.next (); sendMessage (mdlCurrent, current, child); openList.add (child); } } }
/** Sends BP messages starting from parents to children. This version uses constant stack space. */ private void piPropagation (cc.mallet.grmm.types.Tree tree, Object root) { LinkedList openList = new LinkedList (); openList.add (root); while (!openList.isEmpty ()) { Object current = openList.removeFirst (); List children = tree.getChildren (current); for (Iterator it = children.iterator (); it.hasNext ();) { Object child = it.next (); sendMessage (mdlCurrent, current, child); openList.add (child); } } }
/** Sends BP messages starting from parents to children. This version uses constant stack space. */ private void piPropagation (cc.mallet.grmm.types.Tree tree, Object root) { LinkedList openList = new LinkedList (); openList.add (root); while (!openList.isEmpty ()) { Object current = openList.removeFirst (); List children = tree.getChildren (current); for (Iterator it = children.iterator (); it.hasNext ();) { Object child = it.next (); sendMessage (mdlCurrent, current, child); openList.add (child); } } }
private void addSubtree (Object parent, Tree subtree, Object child) { addNode (parent, child); for (Iterator it = subtree.getChildren (child).iterator (); it.hasNext ();) { Object gchild = it.next (); addSubtree (child, subtree, gchild); } }
/** Sends BP messages starting from children to parents. This version uses constant stack space. */ private void lambdaPropagation (cc.mallet.grmm.types.Tree tree, Object root) { LinkedList openList = new LinkedList (); LinkedList closedList = new LinkedList (); openList.addAll (tree.getChildren (root)); while (!openList.isEmpty ()) { Object var = openList.removeFirst (); openList.addAll (tree.getChildren (var)); closedList.addFirst (var); } // Now open list contains all of the nodes (except the root) in reverse topological order. Send the messages. for (Iterator it = closedList.iterator (); it.hasNext ();) { Object child = it.next (); Object parent = tree.getParent (child); sendMessage (mdlCurrent, child, parent); } }
/** Sends BP messages starting from children to parents. This version uses constant stack space. */ private void lambdaPropagation (cc.mallet.grmm.types.Tree tree, Object root) { LinkedList openList = new LinkedList (); LinkedList closedList = new LinkedList (); openList.addAll (tree.getChildren (root)); while (!openList.isEmpty ()) { Object var = openList.removeFirst (); openList.addAll (tree.getChildren (var)); closedList.addFirst (var); } // Now open list contains all of the nodes (except the root) in reverse topological order. Send the messages. for (Iterator it = closedList.iterator (); it.hasNext ();) { Object child = it.next (); Object parent = tree.getParent (child); sendMessage (mdlCurrent, child, parent); } }
private void addSubtree (Object parent, Tree subtree, Object child) { addNode (parent, child); for (Iterator it = subtree.getChildren (child).iterator (); it.hasNext ();) { Object gchild = it.next (); addSubtree (child, subtree, gchild); } }
/** Sends BP messages starting from children to parents. This version uses constant stack space. */ private void lambdaPropagation (cc.mallet.grmm.types.Tree tree, Object root) { LinkedList openList = new LinkedList (); LinkedList closedList = new LinkedList (); openList.addAll (tree.getChildren (root)); while (!openList.isEmpty ()) { Object var = openList.removeFirst (); openList.addAll (tree.getChildren (var)); closedList.addFirst (var); } // Now open list contains all of the nodes (except the root) in reverse topological order. Send the messages. for (Iterator it = closedList.iterator (); it.hasNext ();) { Object child = it.next (); Object parent = tree.getParent (child); sendMessage (mdlCurrent, child, parent); } }
private void addSubtree (Object parent, Tree subtree, Object child) { addNode (parent, child); for (Iterator it = subtree.getChildren (child).iterator (); it.hasNext ();) { Object gchild = it.next (); addSubtree (child, subtree, gchild); } }