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
MaltChainedExceptionpublic LWDependencyGraph(org.maltparser.concurrent.graph.dataformat.DataFormat _dataFormat, SymbolTableHandler _symbolTables, java.lang.String[] inputTokens, java.lang.String defaultRootLabel) throws MaltChainedException
MaltChainedExceptionpublic LWDependencyGraph(org.maltparser.concurrent.graph.dataformat.DataFormat _dataFormat, SymbolTableHandler _symbolTables, java.lang.String[] inputTokens, java.lang.String defaultRootLabel, boolean addEdges) throws MaltChainedException
MaltChainedExceptionpublic void resetTokens(java.lang.String[] inputTokens, java.lang.String defaultRootLabel, boolean addEdges) throws MaltChainedException
MaltChainedExceptionpublic 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
TokenStructureaddTokenNode in interface TokenStructureMaltChainedExceptionpublic TokenNode addTokenNode(int index) throws MaltChainedException
TokenStructureaddTokenNode in interface TokenStructureindex - the index of the token node.MaltChainedExceptionpublic TokenNode getTokenNode(int index)
TokenStructuregetTokenNode in interface TokenStructureindex - the index of the token node.public void addComment(java.lang.String comment, int at_index)
addComment in interface TokenStructurepublic java.util.ArrayList<java.lang.String> getComment(int at_index)
getComment in interface TokenStructurepublic boolean hasComments()
hasComments in interface TokenStructurepublic int nTokenNode()
TokenStructurenTokenNode in interface TokenStructurepublic java.util.SortedSet<java.lang.Integer> getTokenIndices()
TokenStructuregetTokenIndices in interface TokenStructurepublic int getHighestTokenIndex()
TokenStructuregetHighestTokenIndex in interface TokenStructurepublic boolean hasTokens()
TokenStructurehasTokens in interface TokenStructurepublic int getSentenceID()
TokenStructuregetSentenceID in interface TokenStructurepublic void setSentenceID(int sentenceID)
TokenStructuresetSentenceID in interface TokenStructuresentenceID - a sentence IDpublic void clear() throws MaltChainedException
LabeledStructureclear in interface LabeledStructureMaltChainedExceptionpublic SymbolTableHandler getSymbolTables()
LabeledStructuregetSymbolTables in interface LabeledStructurepublic void setSymbolTables(SymbolTableHandler symbolTables)
LabeledStructuresetSymbolTables in interface LabeledStructuresymbolTables - a symbol table handler.public void addLabel(Element element, java.lang.String labelFunction, java.lang.String label) throws MaltChainedException
LabeledStructureaddLabel in interface LabeledStructureelement - a graph element element (a node or a edge).labelFunction - the name of the symbol table.label - the string value of the label.MaltChainedExceptionpublic LabelSet checkOutNewLabelSet() throws MaltChainedException
LabeledStructurecheckOutNewLabelSet in interface LabeledStructureMaltChainedExceptionpublic void checkInLabelSet(LabelSet labelSet) throws MaltChainedException
LabeledStructurecheckInLabelSet in interface LabeledStructurelabelSet - a label set.MaltChainedExceptionpublic Edge addSecondaryEdge(ComparableNode source, ComparableNode target) throws MaltChainedException
addSecondaryEdge in interface SecEdgeStructureMaltChainedExceptionpublic void removeSecondaryEdge(ComparableNode source, ComparableNode target) throws MaltChainedException
removeSecondaryEdge in interface SecEdgeStructureMaltChainedExceptionpublic DependencyNode addDependencyNode() throws MaltChainedException
addDependencyNode in interface DependencyStructureMaltChainedExceptionpublic DependencyNode addDependencyNode(int index) throws MaltChainedException
addDependencyNode in interface DependencyStructureMaltChainedExceptionpublic DependencyNode getDependencyNode(int index) throws MaltChainedException
DependencyStructuregetDependencyNode in interface DependencyStructureindex - the index of the dependency nodeMaltChainedExceptionpublic int nDependencyNode()
nDependencyNode in interface DependencyStructurepublic int getHighestDependencyNodeIndex()
getHighestDependencyNodeIndex in interface DependencyStructurepublic Edge addDependencyEdge(int headIndex, int dependentIndex) throws MaltChainedException
DependencyStructureaddDependencyEdge in interface DependencyStructureheadIndex - the index of the head dependency nodedependentIndex - the index of the dependent dependency nodeMaltChainedExceptionpublic Edge moveDependencyEdge(int newHeadIndex, int dependentIndex) throws MaltChainedException
DependencyStructuremoveDependencyEdge in interface DependencyStructurenewHeadIndex - the index of the new head dependency nodedependentIndex - the index of the dependent dependency nodeMaltChainedExceptionpublic void removeDependencyEdge(int headIndex, int dependentIndex) throws MaltChainedException
DependencyStructureremoveDependencyEdge in interface DependencyStructureheadIndex - the index of the head dependency nodedependentIndex - the index of the dependent dependency nodeMaltChainedExceptionpublic void linkAllTreesToRoot() throws MaltChainedException
DependencyStructurelinkAllTreesToRoot in interface DependencyStructureMaltChainedExceptionpublic int nEdges()
DependencyStructurenEdges in interface DependencyStructurepublic java.util.SortedSet<Edge> getEdges()
getEdges in interface DependencyStructurepublic java.util.SortedSet<java.lang.Integer> getDependencyIndices()
DependencyStructuregetDependencyIndices in interface DependencyStructurepublic DependencyNode getDependencyRoot()
DependencyStructuregetDependencyRoot in interface DependencyStructurepublic boolean hasLabeledDependency(int index)
DependencyStructurehasLabeledDependency in interface DependencyStructureindex - the index of the dependency nodepublic boolean isConnected()
DependencyStructureisConnected in interface DependencyStructurepublic boolean isProjective() throws MaltChainedException
DependencyStructureisProjective in interface DependencyStructureMaltChainedExceptionpublic boolean isSingleHeaded()
DependencyStructureisSingleHeaded in interface DependencyStructurepublic boolean isTree()
DependencyStructureisTree in interface DependencyStructurepublic int nNonProjectiveEdges() throws MaltChainedException
DependencyStructurenNonProjectiveEdges in interface DependencyStructureMaltChainedExceptionpublic LabelSet getDefaultRootEdgeLabels() throws MaltChainedException
getDefaultRootEdgeLabels in interface DependencyStructureMaltChainedExceptionpublic java.lang.String getDefaultRootEdgeLabelSymbol(SymbolTable table) throws MaltChainedException
DependencyStructuregetDefaultRootEdgeLabelSymbol in interface DependencyStructuretable - the symbol table that identifies the label type.MaltChainedExceptionpublic int getDefaultRootEdgeLabelCode(SymbolTable table) throws MaltChainedException
DependencyStructuregetDefaultRootEdgeLabelCode in interface DependencyStructuretable - the symbol table that identifies the label type.MaltChainedExceptionpublic void setDefaultRootEdgeLabel(SymbolTable table, java.lang.String defaultRootSymbol) throws MaltChainedException
DependencyStructuresetDefaultRootEdgeLabel in interface DependencyStructuretable - the symbol table that identifies the label type.defaultRootSymbol - the default root edge labelMaltChainedExceptionpublic void setDefaultRootEdgeLabels(java.lang.String rootLabelOption, java.util.SortedMap<java.lang.String,SymbolTable> edgeSymbolTables) throws MaltChainedException
DependencyStructuresetDefaultRootEdgeLabels in interface DependencyStructurerootLabelOption - the default root label optionedgeSymbolTables - a sorted map that maps the symbol table name to the symbol table object.MaltChainedExceptionpublic java.lang.String toString()
toString in class java.lang.ObjectCopyright 2007-2017 Johan Hall, Jens Nilsson and Joakim Nivre.