List of usage examples for edu.stanford.nlp.semgraph SemanticGraph getChildList
public List<IndexedWord> getChildList(IndexedWord vertex)
From source file:edu.nus.comp.nlp.stanford.UtilParser.java
License:Open Source License
public static DefaultMutableTreeNode toDMTree(IndexedWord root, SemanticGraph dependencies) { if (root == null) { root = dependencies.getFirstRoot(); }/* w w w .j ava 2 s .c o m*/ DefaultMutableTreeNode node = new DefaultMutableTreeNode(); String nodeContent = root.value(); for (SemanticGraphEdge edge : dependencies.edgeIterable()) { if (edge.getDependent().equals(root)) { nodeContent = "<-" + edge.getRelation() + "- " + nodeContent; break; } } node.setUserObject(nodeContent); for (IndexedWord c : dependencies.getChildList(root)) { DefaultMutableTreeNode n = toDMTree(c, dependencies); node.add(n); } return node; }