public final class LWDependencyGraph extends java.lang.Object implements DependencyStructure
Constructor and Description |
---|
LWDependencyGraph(org.maltparser.concurrent.graph.dataformat.DataFormat _dataFormat,
SymbolTableHandler _symbolTables) |
LWDependencyGraph(org.maltparser.concurrent.graph.dataformat.DataFormat _dataFormat,
SymbolTableHandler _symbolTables,
java.lang.String[] inputTokens,
java.lang.String defaultRootLabel) |
LWDependencyGraph(org.maltparser.concurrent.graph.dataformat.DataFormat _dataFormat,
SymbolTableHandler _symbolTables,
java.lang.String[] inputTokens,
java.lang.String defaultRootLabel,
boolean addEdges) |
Modifier and Type | Method and Description |
---|---|
void |
addComment(java.lang.String comment,
int at_index) |
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) |
void |
addLabel(Element element,
java.lang.String labelFunction,
java.lang.String label)
Adds a label label to the graph element element
|
Edge |
addSecondaryEdge(ComparableNode source,
ComparableNode target) |
TokenNode |
addTokenNode()
Adds a token node with index n + 1, where n is the index of the last token node.
|
TokenNode |
addTokenNode(int index)
Adds a token node with index index.
|
void |
checkInLabelSet(LabelSet labelSet)
Checks in a label set.
|
LabelSet |
checkOutNewLabelSet()
Checks out a new label set from the structure.
|
void |
clear()
Resets the structure.
|
protected DependencyNode |
findComponent(int nodeIndex) |
java.util.ArrayList<java.lang.String> |
getComment(int at_index) |
org.maltparser.concurrent.graph.dataformat.DataFormat |
getDataFormat() |
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() |
int |
getHighestTokenIndex()
Returns the index of the last token node.
|
protected java.util.List<DependencyNode> |
getListOfDependents(int nodeIndex) |
protected java.util.List<DependencyNode> |
getListOfLeftDependents(int nodeIndex) |
protected java.util.List<DependencyNode> |
getListOfRightDependents(int nodeIndex) |
LWNode |
getNode(int nodeIndex) |
protected int |
getRank(int nodeIndex) |
int |
getSentenceID()
Returns the sentence ID
|
protected java.util.SortedSet<DependencyNode> |
getSortedSetOfDependents(int nodeIndex) |
protected java.util.SortedSet<DependencyNode> |
getSortedSetOfLeftDependents(int nodeIndex) |
protected java.util.SortedSet<DependencyNode> |
getSortedSetOfRightDependents(int nodeIndex) |
SymbolTableHandler |
getSymbolTables()
Returns the symbol table handler.
|
java.util.SortedSet<java.lang.Integer> |
getTokenIndices()
Returns a sorted set of integers {s,...
|
TokenNode |
getTokenNode(int index)
Returns the token node with index index.
|
boolean |
hasComments() |
protected boolean |
hasDependent(int nodeIndex) |
boolean |
hasLabeledDependency(int index)
Returns true if the head edge of the dependency node with index is labeled, otherwise false.
|
protected boolean |
hasLeftDependent(int nodeIndex) |
protected boolean |
hasRightDependent(int nodeIndex) |
boolean |
hasTokens()
Returns true if the token structure (sentence) has any token nodes, 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 |
isTree()
Returns true if the dependency structure are a tree (isConnected() && isSingleHeaded()), otherwise false.
|
void |
linkAllTreesToRoot()
Links all subtrees to the root of the dependency structure.
|
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 |
nNodes() |
int |
nNonProjectiveEdges()
Returns the number of non-projective edges in the dependency structure.
|
int |
nTokenNode()
Returns the number of token nodes in the token structure (sentence).
|
void |
removeDependencyEdge(int headIndex,
int dependentIndex)
Remove an edge from the head to the dependent identified by the indices of the dependency nodes.
|
void |
removeSecondaryEdge(ComparableNode source,
ComparableNode target) |
void |
resetTokens(java.lang.String[] inputTokens,
java.lang.String defaultRootLabel,
boolean addEdges) |
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 |
setSentenceID(int sentenceID)
Sets the sentence ID
|
void |
setSymbolTables(SymbolTableHandler symbolTables)
Sets the symbol table handler.
|
java.lang.String |
toString() |
public LWDependencyGraph(org.maltparser.concurrent.graph.dataformat.DataFormat _dataFormat, SymbolTableHandler _symbolTables) throws MaltChainedException
MaltChainedException
public LWDependencyGraph(org.maltparser.concurrent.graph.dataformat.DataFormat _dataFormat, SymbolTableHandler _symbolTables, java.lang.String[] inputTokens, java.lang.String defaultRootLabel) throws MaltChainedException
MaltChainedException
public LWDependencyGraph(org.maltparser.concurrent.graph.dataformat.DataFormat _dataFormat, SymbolTableHandler _symbolTables, java.lang.String[] inputTokens, java.lang.String defaultRootLabel, boolean addEdges) throws MaltChainedException
MaltChainedException
public void resetTokens(java.lang.String[] inputTokens, java.lang.String defaultRootLabel, boolean addEdges) throws MaltChainedException
MaltChainedException
public org.maltparser.concurrent.graph.dataformat.DataFormat getDataFormat()
public int nNodes()
protected boolean hasDependent(int nodeIndex)
protected boolean hasLeftDependent(int nodeIndex)
protected boolean hasRightDependent(int nodeIndex)
protected java.util.List<DependencyNode> getListOfLeftDependents(int nodeIndex)
protected java.util.SortedSet<DependencyNode> getSortedSetOfLeftDependents(int nodeIndex)
protected java.util.List<DependencyNode> getListOfRightDependents(int nodeIndex)
protected java.util.SortedSet<DependencyNode> getSortedSetOfRightDependents(int nodeIndex)
protected java.util.List<DependencyNode> getListOfDependents(int nodeIndex)
protected java.util.SortedSet<DependencyNode> getSortedSetOfDependents(int nodeIndex)
protected int getRank(int nodeIndex)
protected DependencyNode findComponent(int nodeIndex)
public TokenNode addTokenNode() throws MaltChainedException
TokenStructure
addTokenNode
in interface TokenStructure
MaltChainedException
public TokenNode addTokenNode(int index) throws MaltChainedException
TokenStructure
addTokenNode
in interface TokenStructure
index
- the index of the token node.MaltChainedException
public TokenNode getTokenNode(int index)
TokenStructure
getTokenNode
in interface TokenStructure
index
- the index of the token node.public void addComment(java.lang.String comment, int at_index)
addComment
in interface TokenStructure
public java.util.ArrayList<java.lang.String> getComment(int at_index)
getComment
in interface TokenStructure
public boolean hasComments()
hasComments
in interface TokenStructure
public int nTokenNode()
TokenStructure
nTokenNode
in interface TokenStructure
public java.util.SortedSet<java.lang.Integer> getTokenIndices()
TokenStructure
getTokenIndices
in interface TokenStructure
public int getHighestTokenIndex()
TokenStructure
getHighestTokenIndex
in interface TokenStructure
public boolean hasTokens()
TokenStructure
hasTokens
in interface TokenStructure
public int getSentenceID()
TokenStructure
getSentenceID
in interface TokenStructure
public void setSentenceID(int sentenceID)
TokenStructure
setSentenceID
in interface TokenStructure
sentenceID
- a sentence IDpublic void clear() throws MaltChainedException
LabeledStructure
clear
in interface LabeledStructure
MaltChainedException
public SymbolTableHandler getSymbolTables()
LabeledStructure
getSymbolTables
in interface LabeledStructure
public void setSymbolTables(SymbolTableHandler symbolTables)
LabeledStructure
setSymbolTables
in interface LabeledStructure
symbolTables
- a symbol table handler.public void addLabel(Element element, java.lang.String labelFunction, java.lang.String label) throws MaltChainedException
LabeledStructure
addLabel
in interface LabeledStructure
element
- a graph element element (a node or a edge).labelFunction
- the name of the symbol table.label
- the string value of the label.MaltChainedException
public LabelSet checkOutNewLabelSet() throws MaltChainedException
LabeledStructure
checkOutNewLabelSet
in interface LabeledStructure
MaltChainedException
public void checkInLabelSet(LabelSet labelSet) throws MaltChainedException
LabeledStructure
checkInLabelSet
in interface LabeledStructure
labelSet
- a label set.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 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
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
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
public void linkAllTreesToRoot() throws MaltChainedException
DependencyStructure
linkAllTreesToRoot
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
public DependencyNode getDependencyRoot()
DependencyStructure
getDependencyRoot
in interface DependencyStructure
public boolean hasLabeledDependency(int index)
DependencyStructure
hasLabeledDependency
in interface DependencyStructure
index
- the index of the dependency nodepublic boolean isConnected()
DependencyStructure
isConnected
in interface DependencyStructure
public boolean isProjective() throws MaltChainedException
DependencyStructure
isProjective
in interface DependencyStructure
MaltChainedException
public boolean isSingleHeaded()
DependencyStructure
isSingleHeaded
in interface DependencyStructure
public boolean isTree()
DependencyStructure
isTree
in interface DependencyStructure
public int nNonProjectiveEdges() throws MaltChainedException
DependencyStructure
nNonProjectiveEdges
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 java.lang.String toString()
toString
in class java.lang.Object
Copyright 2007-2017 Johan Hall, Jens Nilsson and Joakim Nivre.