public class DependencyGraph extends Sentence implements DependencyStructure
comments, sentenceID, terminalNodes, terminalPool
labelSetPool, numberOfComponents, symbolTables
Constructor and Description |
---|
DependencyGraph(SymbolTableHandler symbolTables) |
Modifier and Type | Method and Description |
---|---|
protected Edge |
addDependencyEdge(DependencyNode head,
DependencyNode dependent) |
Edge |
addDependencyEdge(int headIndex,
int dependentIndex)
Adds an edge from the head to the dependent identified by the indices of the dependency nodes.
|
DependencyNode |
addDependencyNode() |
DependencyNode |
addDependencyNode(int index) |
Edge |
addSecondaryEdge(ComparableNode source,
ComparableNode target) |
void |
clear()
Resets the structure.
|
int |
getDefaultRootEdgeLabelCode(SymbolTable table)
Returns the default edge label of the root as an integer value.
|
LabelSet |
getDefaultRootEdgeLabels() |
java.lang.String |
getDefaultRootEdgeLabelSymbol(SymbolTable table)
Returns the default edge label of the root as a string value.
|
java.util.SortedSet<java.lang.Integer> |
getDependencyIndices()
Returns a sorted set of integers {0,s,..n} , where each index i identifies a dependency node.
|
DependencyNode |
getDependencyNode(int index)
Returns the dependency node identified by index if it exists, otherwise null.
|
DependencyNode |
getDependencyRoot()
Returns the root of the dependency structure.
|
java.util.SortedSet<Edge> |
getEdges() |
int |
getHighestDependencyNodeIndex() |
boolean |
hasLabeledDependency(int index)
Returns true if the head edge of the dependency node with index is labeled, otherwise false.
|
boolean |
isConnected()
Returns true if all nodes in the dependency structure are connected, otherwise false.
|
boolean |
isProjective()
Returns true if all edges in the dependency structure are projective, otherwise false.
|
boolean |
isSingleHeaded()
Returns true if all dependency nodes have at most one incoming edge, otherwise false.
|
boolean |
isSingleHeadedConstraint() |
boolean |
isTree()
Returns true if the dependency structure are a tree (isConnected() && isSingleHeaded()), otherwise false.
|
protected DependencyNode |
link(DependencyNode x,
DependencyNode y) |
void |
linkAllTreesToRoot()
Links all subtrees to the root of the dependency structure.
|
protected Edge |
moveDependencyEdge(DependencyNode newHead,
DependencyNode dependent) |
Edge |
moveDependencyEdge(int newHeadIndex,
int dependentIndex)
Replace the head of the dependent with a new head.
|
int |
nDependencyNode() |
int |
nEdges()
Returns the number of edges
|
int |
nNonProjectiveEdges()
Returns the number of non-projective edges in the dependency structure.
|
void |
removeDependencyEdge(int headIndex,
int dependentIndex)
Remove an edge from the head to the dependent identified by the indices of the dependency nodes.
|
protected void |
removeDependencyEdge(Node head,
Node dependent) |
void |
removeSecondaryEdge(ComparableNode source,
ComparableNode target) |
void |
setDefaultRootEdgeLabel(SymbolTable table,
java.lang.String defaultRootSymbol)
Sets the default edge label of the root.
|
void |
setDefaultRootEdgeLabels(java.lang.String rootLabelOption,
java.util.SortedMap<java.lang.String,SymbolTable> edgeSymbolTables)
Sets the default edge label of the root according to the default root label option
|
void |
setSingleHeadedConstraint(boolean singleHeadedConstraint) |
java.lang.String |
toString() |
addComment, addTokenNode, addTokenNode, getComment, getHighestTokenIndex, getOrAddTerminalNode, getSentenceID, getTokenIndices, getTokenNode, hasComments, hasTokens, nTokenNode, setSentenceID, update
addLabel, checkInLabelSet, checkOutNewLabelSet, getSymbolTables, setSymbolTables
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addComment, addTokenNode, addTokenNode, getComment, getHighestTokenIndex, getSentenceID, getTokenIndices, getTokenNode, hasComments, hasTokens, nTokenNode, setSentenceID
addLabel, checkInLabelSet, checkOutNewLabelSet, getSymbolTables, setSymbolTables
public DependencyGraph(SymbolTableHandler symbolTables) throws MaltChainedException
MaltChainedException
public DependencyNode addDependencyNode() throws MaltChainedException
addDependencyNode
in interface DependencyStructure
MaltChainedException
public DependencyNode addDependencyNode(int index) throws MaltChainedException
addDependencyNode
in interface DependencyStructure
MaltChainedException
public DependencyNode getDependencyNode(int index) throws MaltChainedException
DependencyStructure
getDependencyNode
in interface DependencyStructure
index
- the index of the dependency nodeMaltChainedException
public int nDependencyNode()
nDependencyNode
in interface DependencyStructure
public int getHighestDependencyNodeIndex()
getHighestDependencyNodeIndex
in interface DependencyStructure
public Edge addDependencyEdge(int headIndex, int dependentIndex) throws MaltChainedException
DependencyStructure
addDependencyEdge
in interface DependencyStructure
headIndex
- the index of the head dependency nodedependentIndex
- the index of the dependent dependency nodeMaltChainedException
protected Edge addDependencyEdge(DependencyNode head, DependencyNode dependent) throws MaltChainedException
MaltChainedException
public Edge moveDependencyEdge(int newHeadIndex, int dependentIndex) throws MaltChainedException
DependencyStructure
moveDependencyEdge
in interface DependencyStructure
newHeadIndex
- the index of the new head dependency nodedependentIndex
- the index of the dependent dependency nodeMaltChainedException
protected Edge moveDependencyEdge(DependencyNode newHead, DependencyNode dependent) throws MaltChainedException
MaltChainedException
public void removeDependencyEdge(int headIndex, int dependentIndex) throws MaltChainedException
DependencyStructure
removeDependencyEdge
in interface DependencyStructure
headIndex
- the index of the head dependency nodedependentIndex
- the index of the dependent dependency nodeMaltChainedException
protected void removeDependencyEdge(Node head, Node dependent) throws MaltChainedException
MaltChainedException
public Edge addSecondaryEdge(ComparableNode source, ComparableNode target) throws MaltChainedException
addSecondaryEdge
in interface SecEdgeStructure
MaltChainedException
public void removeSecondaryEdge(ComparableNode source, ComparableNode target) throws MaltChainedException
removeSecondaryEdge
in interface SecEdgeStructure
MaltChainedException
public boolean hasLabeledDependency(int index) throws MaltChainedException
DependencyStructure
hasLabeledDependency
in interface DependencyStructure
index
- the index of the dependency nodeMaltChainedException
public boolean isConnected()
DependencyStructure
isConnected
in interface DependencyStructure
public boolean isProjective() throws MaltChainedException
DependencyStructure
isProjective
in interface DependencyStructure
MaltChainedException
public boolean isTree()
DependencyStructure
isTree
in interface DependencyStructure
public boolean isSingleHeaded()
DependencyStructure
isSingleHeaded
in interface DependencyStructure
public boolean isSingleHeadedConstraint()
public void setSingleHeadedConstraint(boolean singleHeadedConstraint)
public int nNonProjectiveEdges() throws MaltChainedException
DependencyStructure
nNonProjectiveEdges
in interface DependencyStructure
MaltChainedException
public int nEdges()
DependencyStructure
nEdges
in interface DependencyStructure
public java.util.SortedSet<Edge> getEdges()
getEdges
in interface DependencyStructure
public java.util.SortedSet<java.lang.Integer> getDependencyIndices()
DependencyStructure
getDependencyIndices
in interface DependencyStructure
protected DependencyNode link(DependencyNode x, DependencyNode y) throws MaltChainedException
MaltChainedException
public void linkAllTreesToRoot() throws MaltChainedException
DependencyStructure
linkAllTreesToRoot
in interface DependencyStructure
MaltChainedException
public LabelSet getDefaultRootEdgeLabels() throws MaltChainedException
getDefaultRootEdgeLabels
in interface DependencyStructure
MaltChainedException
public java.lang.String getDefaultRootEdgeLabelSymbol(SymbolTable table) throws MaltChainedException
DependencyStructure
getDefaultRootEdgeLabelSymbol
in interface DependencyStructure
table
- the symbol table that identifies the label type.MaltChainedException
public int getDefaultRootEdgeLabelCode(SymbolTable table) throws MaltChainedException
DependencyStructure
getDefaultRootEdgeLabelCode
in interface DependencyStructure
table
- the symbol table that identifies the label type.MaltChainedException
public void setDefaultRootEdgeLabel(SymbolTable table, java.lang.String defaultRootSymbol) throws MaltChainedException
DependencyStructure
setDefaultRootEdgeLabel
in interface DependencyStructure
table
- the symbol table that identifies the label type.defaultRootSymbol
- the default root edge labelMaltChainedException
public void setDefaultRootEdgeLabels(java.lang.String rootLabelOption, java.util.SortedMap<java.lang.String,SymbolTable> edgeSymbolTables) throws MaltChainedException
DependencyStructure
setDefaultRootEdgeLabels
in interface DependencyStructure
rootLabelOption
- the default root label optionedgeSymbolTables
- a sorted map that maps the symbol table name to the symbol table object.MaltChainedException
public void clear() throws MaltChainedException
LabeledStructure
clear
in interface LabeledStructure
clear
in class Sentence
MaltChainedException
public DependencyNode getDependencyRoot()
DependencyStructure
getDependencyRoot
in interface DependencyStructure
Copyright 2007-2017 Johan Hall, Jens Nilsson and Joakim Nivre.