|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.jscience.ml.tigerxml.GraphNode
public class GraphNode
Represents a node in the syntax tree, either a terminal node or a non-terminal node.
GraphNode is a generalization over NT
(non-terminal) and T (terminal)
nodes. GraphNode implements all methods and attributes that
are common to both, NT and T nodes.
NT and T are subclasses of this class and
inherit all methods. Furthermore, they implement methods which are
specific to non-terminal and terminal nodes respectively.It is possible to cast one class to one of the others:
GraphNode instances can be cast to NT or
T, depending on the GraphNode instance's
.isTerminal() value.
NT and T instances can be cast to
GraphNode.
Corpus corp = new Corpus("sampleTIGER");
GraphNode gn = corp.getGraphNodeBySpan("s1_1..s1_3");
if (gn.isTerminal()) {
System.out.println( (T)gn.getWord());
} else {
System.out.println( (NT)gn.toTreeString());
}
NT,
T,
Serialized Form| Field Summary | |
|---|---|
protected int |
verbosity
The higher this value the more process and debug information will written to stderr. |
| Constructor Summary | |
|---|---|
GraphNode()
Creates an empty instance of GraphNode with all values set to null or emty. |
|
GraphNode(java.lang.String id,
Sentence sentence,
NT mother,
java.lang.String edge2mother,
boolean isTerminal,
int index)
Creates an instance of GraphNode with alls values set as given. |
|
| Method Summary | |
|---|---|
boolean |
before(GraphNode node)
Returns true if the leftmost terminal of the tree whose root node this node is linearly preceedes the leftmost terminal of the tree whose root node the input node is. |
boolean |
dominates(GraphNode node)
Returns true if this node dominates the input node in the syntax tree. |
boolean |
equals(GraphNode otherNode)
Returns true if the two nodes are identical. |
Corpus |
getCorpus()
Returns the corpus this GraphNode is part of. |
NT |
getDominatingNodeByCat(java.lang.String cat)
Returns the nearest dominating node with category cat, null if there is no such node If this node has the category cat it will be returned itself. |
java.lang.String |
getEdge2Mother()
Returns the label of the edge going to the mother node. |
java.lang.String |
getEdge2SecMother(NT s_mother)
Returns the label that belongs to the edge going to the secondary mother s_mother. |
java.lang.String |
getId()
Returns the ID String of this node. |
int |
getIndex()
Returns the position index of this node in the ArrayList holding it. |
T |
getLeftmostTerminal()
Returns the leftmost terminal of the tree whose root node this node is. |
NT |
getMother()
Returns the mother node. |
Path |
getPath(GraphNode toNode)
Returns a Path object representing
the path through the syntax tree which connects
this node and the input node. |
java.util.ArrayList |
getSecMothers()
Returns an ArrayList of the secondary mothers of this node. |
Sentence |
getSentence()
Returns the sentence this GraphNode is part of. |
java.lang.String |
getText()
Returns the surface string of this node. |
int |
getVerbosity()
Gets the currently set level of verbosity of this instance. |
boolean |
hasMother()
Returns true if this node has a mother node. |
boolean |
hasSecMothers()
Returns true if this node has any secondary mothers. |
boolean |
hasSurfaceWord(java.lang.String word)
Returns true if one of the leaves of the subtree whose root this node is has the input word as its word |
boolean |
isDominatedBy(GraphNode node)
Returns true if this node is dominated by the input node in the syntax tree. |
boolean |
isDominatedBy(java.lang.String cat)
Returns true if there is a dominating node that has the category cat. |
boolean |
isTerminal()
Returns true if this node is a terminal node (T), false if not. |
void |
printNode()
Prints identifying information about this node. |
void |
printNode(java.lang.String comment)
Prints a comment and identifying information about this node. |
void |
printNodeErr()
Prints identifying information on this node to stderr. |
void |
printNodeErr(java.lang.String comment)
Prints a comment and identifying information on this node to stderr. |
void |
printTree()
Prints all daughters recursively in a tree structure to stdout. |
void |
printTreeErr()
Prints all daughters recursively in a tree structure to stderr. |
void |
setEdge2Mother(java.lang.String newedge2mother)
Sets the label String of the edge going to the mother node. |
void |
setId(java.lang.String newid)
Sets the ID String of this node. |
void |
setIndex(int index)
Sets the position index in the ArrayList holding this node. |
void |
setMother(NT newmother)
Sets the mother of this node. |
void |
setSecMother(NT mother,
java.lang.String label)
Sets a secondary mother of this node and the label of the edge going to it. |
void |
setSentence(Sentence sentence)
Sets the sentence this GraphNode is part of. |
void |
setTerminal(boolean isTerminal)
Sets whether this node is a terminal. |
void |
setVerbosity(int verbosity)
Sets the currently set level of verbosity of this instance. |
java.lang.String |
toNodeInfoString()
Returns identifying information about this node as a string. |
java.lang.String |
toString()
Returns the String representation of this node. |
java.lang.String |
toTreeString()
Returns the tree structure of this GraphNode as a string. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected int verbosity
| Constructor Detail |
|---|
public GraphNode()
public GraphNode(java.lang.String id,
Sentence sentence,
NT mother,
java.lang.String edge2mother,
boolean isTerminal,
int index)
id - The ID-String of the node.sentence - The sentence this instance of GraphNode is part of.mother - The mother node (can only be a NT).edge2mother - The label of the edge going to the mother node.isTerminal - True/false for whether this instance is an instance of T.index - The position index of this node in the ArrayList holding it.| Method Detail |
|---|
public boolean isTerminal()
T.
T.Tpublic void setTerminal(boolean isTerminal)
isTerminal - True if this node is a terminal.public java.lang.String getId()
public void setId(java.lang.String newid)
public Sentence getSentence()
public void setSentence(Sentence sentence)
public Corpus getCorpus()
public NT getMother()
NT myNonTerminal = (NT) someGraphNode.getMother();
public void setMother(NT newmother)
public java.lang.String getEdge2Mother()
public void setEdge2Mother(java.lang.String newedge2mother)
public void setSecMother(NT mother,
java.lang.String label)
public boolean hasSecMothers()
public java.util.ArrayList getSecMothers()
public java.lang.String getEdge2SecMother(NT s_mother)
public int getIndex()
public void setIndex(int index)
public java.lang.String toString()
toString in class java.lang.Objectpublic boolean equals(GraphNode otherNode)
public boolean hasMother()
null from getMother()
would cause trouble.
public void printNodeErr()
public void printNodeErr(java.lang.String comment)
comment - A comment precding the printed information.public java.lang.String getText()
public boolean hasSurfaceWord(java.lang.String word)
public boolean isDominatedBy(java.lang.String cat)
public NT getDominatingNodeByCat(java.lang.String cat)
public Path getPath(GraphNode toNode)
Path object representing
the path through the syntax tree which connects
this node and the input node.
Path object representing
the path which connects this and the input node.public boolean isDominatedBy(GraphNode node)
public boolean dominates(GraphNode node)
public java.lang.String toTreeString()
public java.lang.String toNodeInfoString()
public void printTree()
public void printTreeErr()
public void printNode()
public void printNode(java.lang.String comment)
comment - A comment precding the printed information.public boolean before(GraphNode node)
public T getLeftmostTerminal()
public int getVerbosity()
public void setVerbosity(int verbosity)
verbosity - The level of verbosity.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||