public class TreebankNodeUtil extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
TreebankNodeUtil.TreebankNodePath
Representation of a path from one TreebankNode to another, via a common ancestor in the tree.
|
| Constructor and Description |
|---|
TreebankNodeUtil() |
| Modifier and Type | Method and Description |
|---|---|
static TreebankNode |
getAncestorWithType(TreebankNode node,
String type) |
static int |
getDepth(TreebankNode node)
Calculates the depth of the TreebankNode.
|
static TreebankNode |
getParent(TreebankNode node) |
static TreebankNodeUtil.TreebankNodePath |
getPath(TreebankNode source,
TreebankNode target)
Get the path from the source TreebankNode to the target TreebankNode via the least common
ancestor.
|
static List<TreebankNode> |
getPathToRoot(TreebankNode startNode)
Find the path from a TreebankNode to the root of the tree it belongs to.
|
static TopTreebankNode |
getTopNode(TreebankNode node) |
static TreebankNode |
newNode(JCas jCas,
int begin,
int end,
String nodeType)
Create a leaf TreebankNode in a JCas.
|
static TreebankNode |
newNode(JCas jCas,
String nodeType,
TreebankNode... children)
Create a branch TreebankNode in a JCas.
|
static void |
print(PrintStream out,
TreebankNode node)
A "pretty print" of this node that may be useful for e.g.
|
static TreebankNode |
selectHighestCoveredTreebankNode(JCas jCas,
Annotation annotation)
Selects the highest TreebankNode in the parse tree that is at least partially covered by the
given annotation.
|
static TreebankNode |
selectHighestMatchingTreebankNode(JCas jCas,
Annotation annotation)
Selects the highest TreebankNode in the parse tree that has the same span as the given
annotation.
|
static TreebankNode |
selectMatchingLeaf(JCas jCas,
Annotation annotation)
Selects a single TreebankNode leaf that has the same span as the given annotation.
|
static String |
toTreebankString(TreebankNode node)
Format the TreebankNode as a Penn-Treebank-style parenthesized string.
|
public TreebankNodeUtil()
public static TreebankNode getAncestorWithType(TreebankNode node, String type)
public static int getDepth(TreebankNode node)
node - The TreebankNode whose depth is to be calculated.public static TreebankNode getParent(TreebankNode node)
public static TreebankNodeUtil.TreebankNodePath getPath(TreebankNode source, TreebankNode target)
source - The TreebankNode where the path should start.target - The TreebankNode where the path should end.public static List<TreebankNode> getPathToRoot(TreebankNode startNode)
startNode - The start node of the pathpublic static TopTreebankNode getTopNode(TreebankNode node)
public static TreebankNode newNode(JCas jCas, int begin, int end, String nodeType)
jCas - The JCas which the annotation should be added to.begin - The begin offset of the node.end - The end offset of the node.nodeType - The part of speech tag of the node.public static TreebankNode newNode(JCas jCas, String nodeType, TreebankNode... children)
jCas - The JCas which the annotation should be added to.nodeType - The phrase type tag of the node.children - The TreebankNode children of the node.public static void print(PrintStream out, TreebankNode node)
public static TreebankNode selectHighestCoveredTreebankNode(JCas jCas, Annotation annotation)
jCas - The JCas containing the TreebankNodes.annotation - The Annotation whose span should be matched.public static TreebankNode selectHighestMatchingTreebankNode(JCas jCas, Annotation annotation)
jCas - The JCas containing the TreebankNodes.annotation - The Annotation whose span should be matched.public static TreebankNode selectMatchingLeaf(JCas jCas, Annotation annotation)
jCas - The JCas containing the TreebankNodes.annotation - The Annotation whose span should match a TreebankNode leaf.public static String toTreebankString(TreebankNode node)
node - The TreebankNode to be formatted.Copyright © 2014. All rights reserved.