public class TreeView extends View
View
by providing functions to
get and set Tree
objects.Modifier and Type | Field and Description |
---|---|
protected boolean |
firstTree |
protected boolean |
isDependencyTree |
protected List<Tree<String>> |
trees |
constituents, endSpan, relations, score, startSpan, textAnnotation, tokensToConstituents, viewGenerator, viewName
Constructor and Description |
---|
TreeView(String viewName,
String viewGenerator,
TextAnnotation text,
double score) |
TreeView(String viewName,
TextAnnotation text)
Create a new TreeView with default
View.viewGenerator and View.score . |
Modifier and Type | Method and Description |
---|---|
protected void |
addDependencyTree(Tree<Pair<String,Integer>> depTree,
int sentStart,
Constituent parent) |
protected void |
addDependencyTreeWithHack(Tree<Pair<String,Integer>> depTree,
Constituent parent,
int sentenceStart) |
protected void |
addParseTree(Tree<Pair<String,IntPair>> spanLabeledTree,
Constituent root,
int sentenceStartPosition)
Transforms an unscored input tree into the constituent-relation graph
|
protected void |
addScoredParseTree(Tree<Pair<String,IntPair>> spanLabeledTree,
Tree<Double> scores,
Constituent root,
int sentenceStartPosition)
Transforms a scored input tree into the constituent-relation graph
|
protected Tree<String> |
buildTree(Constituent root) |
Tree<Constituent> |
getConstituentTree(int sentenceId) |
static Constituent |
getParent(Constituent constituent)
Gets the parent of a constituent.
|
Constituent |
getParsePhrase(Constituent c)
Finds the highest node in the parse tree that contains the input constituent.
|
Constituent |
getRootConstituent(int sentenceId)
Gets the root constituent of the tree for the given sentence
|
Constituent |
getRootConstituent(Sentence sentence)
Gets the root constituent of the tree for the given sentence
|
Tree<String> |
getTree(int sentenceId)
Get the
Tree representation of the
tree for the given sentence. |
Constituent |
getTreeRoot(int sentenceId)
Get the root constituent of the tree that covers a sentence
|
Constituent |
getTreeRoot(Sentence s)
Get the root constituent of the tree that covers a sentence
|
static boolean |
isLeaf(Constituent c)
Checks if a constituent is a leaf of a tree.
|
static boolean |
isRoot(Constituent c)
Checks if a constituent is a root node of a tree.
|
protected Tree<String> |
makeTree(Constituent root) |
protected void |
makeTrees()
Makes the tree objects.
|
void |
setDependencyTree(int sentenceId,
Tree<Pair<String,Integer>> depTree)
Set the dependency tree of hte
sentenceId th sentence. |
void |
setDependencyTree(int sentenceId,
Tree<Pair<String,Integer>> depTree,
double treeScore)
Set the dependency tree for a specified sentence.
|
protected void |
setDependencyTreeSwitch(Constituent root) |
void |
setParseTree(int sentenceId,
Tree<String> tree)
Set the parse tree of the
sentenceId th sentence. |
void |
setScoredParseTree(int sentenceId,
Tree<String> tree,
Tree<Double> scores)
Set the parse tree of the
sentenceId th sentence. |
String |
toString() |
addConstituent, addRelation, containsConstituent, count, getConstituents, getConstituentsCovering, getConstituentsCoveringCharSpan, getConstituentsCoveringSpan, getConstituentsCoveringToken, getConstituentsCoveringTokens, getConstituentsOverlappingCharSpan, getConstituentsWithSpan, getEndSpan, getFilteredConstituents, getLabelsCovering, getLabelsCoveringSpan, getLabelsCoveringToken, getLabelsCoveringTokens, getNumberOfConstituents, getRelations, getRestrictedView, getScore, getStartSpan, getTextAnnotation, getViewCoveringSpan, getViewCoveringToken, getViewCoveringTokens, getViewGenerator, getViewName, iterator, orderBy, removeAllConsituents, removeAllRelations, removeAttributes, removeConstituent, removeRelation, select, unique, where
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
forEach, spliterator
protected boolean isDependencyTree
protected boolean firstTree
public TreeView(String viewName, TextAnnotation text)
View.viewGenerator
and View.score
.public TreeView(String viewName, String viewGenerator, TextAnnotation text, double score)
public static boolean isRoot(Constituent c)
public static boolean isLeaf(Constituent c)
public static Constituent getParent(Constituent constituent)
protected Tree<String> buildTree(Constituent root)
public Constituent getRootConstituent(int sentenceId)
public Constituent getRootConstituent(Sentence sentence)
public Tree<String> getTree(int sentenceId)
Tree
representation of the
tree for the given sentence.protected Tree<String> makeTree(Constituent root)
protected void setDependencyTreeSwitch(Constituent root)
protected void makeTrees()
public Constituent getTreeRoot(int sentenceId)
public Constituent getTreeRoot(Sentence s)
public void setParseTree(int sentenceId, Tree<String> tree)
sentenceId
th sentence.
Note: The same TreeView cannot contain both the parse tree and the dependency tree and will throw an exception if an attempt is made to set the parse tree in a view that has a dependency tree.
public void setDependencyTree(int sentenceId, Tree<Pair<String,Integer>> depTree)
sentenceId
th sentence. Each node in the
dependency tree specifies both the token and its position with respect to the start of the
sentence, not the entire TextAnnotation.
Note: The same TreeView cannot contain both the parse tree and the dependency tree and will throw an exception if an attempt is made to set the dependency tree of a view that has a phrase-structure tree.
public void setDependencyTree(int sentenceId, Tree<Pair<String,Integer>> depTree, double treeScore)
Note: The same TreeView cannot contain both the parse tree and the dependency tree and will throw an exception if an attempt is made to set the dependency tree of a view that has a phrase-structure tree.
protected void addDependencyTree(Tree<Pair<String,Integer>> depTree, int sentStart, Constituent parent)
protected void addDependencyTreeWithHack(Tree<Pair<String,Integer>> depTree, Constituent parent, int sentenceStart)
public void setScoredParseTree(int sentenceId, Tree<String> tree, Tree<Double> scores)
sentenceId
th sentence.protected void addScoredParseTree(Tree<Pair<String,IntPair>> spanLabeledTree, Tree<Double> scores, Constituent root, int sentenceStartPosition)
protected void addParseTree(Tree<Pair<String,IntPair>> spanLabeledTree, Constituent root, int sentenceStartPosition)
public Tree<Constituent> getConstituentTree(int sentenceId)
public Constituent getParsePhrase(Constituent c) throws Exception
c
- The input constituent. This could be from any view.Exception
Copyright © 2017. All rights reserved.