MaltParser 1.4.1

org.maltparser.core.syntaxgraph
Class DependencyGraph

java.lang.Object
  extended by org.maltparser.core.syntaxgraph.SyntaxGraph
      extended by org.maltparser.core.syntaxgraph.Sentence
          extended by org.maltparser.core.syntaxgraph.DependencyGraph
All Implemented Interfaces:
Observer, DependencyStructure, LabeledStructure, SecEdgeStructure, Structure, TokenStructure

public class DependencyGraph
extends Sentence
implements DependencyStructure

Author:
Johan Hall

Field Summary
 
Fields inherited from class org.maltparser.core.syntaxgraph.Sentence
sentenceID, terminalNodes, terminalPool
 
Fields inherited from class org.maltparser.core.syntaxgraph.SyntaxGraph
labelSetPool, numberOfComponents, symbolTables
 
Constructor Summary
DependencyGraph(SymbolTableHandler symbolTables)
           
 
Method Summary
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()
           
 String getDefaultRootEdgeLabelSymbol(SymbolTable table)
          Returns the default edge label of the root as a string value.
 SortedSet<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.
 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, String defaultRootSymbol)
          Sets the default edge label of the root.
 void setDefaultRootEdgeLabels(String rootLabelOption, SortedMap<String,SymbolTable> edgeSymbolTables)
          Sets the default edge label of the root according to the default root label option
 void setSingleHeadedConstraint(boolean singleHeadedConstraint)
           
 String toString()
           
 
Methods inherited from class org.maltparser.core.syntaxgraph.Sentence
addTokenNode, addTokenNode, getHighestTokenIndex, getOrAddTerminalNode, getSentenceID, getTokenIndices, getTokenNode, hasTokens, nTokenNode, setSentenceID, update
 
Methods inherited from class org.maltparser.core.syntaxgraph.SyntaxGraph
addLabel, checkInLabelSet, checkOutNewLabelSet, getSymbolTables, setSymbolTables
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.maltparser.core.syntaxgraph.TokenStructure
addTokenNode, addTokenNode, getHighestTokenIndex, getSentenceID, getTokenIndices, getTokenNode, hasTokens, nTokenNode, setSentenceID
 
Methods inherited from interface org.maltparser.core.syntaxgraph.LabeledStructure
addLabel, checkInLabelSet, checkOutNewLabelSet, getSymbolTables, setSymbolTables
 

Constructor Detail

DependencyGraph

public DependencyGraph(SymbolTableHandler symbolTables)
                throws MaltChainedException
Throws:
MaltChainedException
Method Detail

addDependencyNode

public DependencyNode addDependencyNode()
                                 throws MaltChainedException
Specified by:
addDependencyNode in interface DependencyStructure
Throws:
MaltChainedException

addDependencyNode

public DependencyNode addDependencyNode(int index)
                                 throws MaltChainedException
Specified by:
addDependencyNode in interface DependencyStructure
Throws:
MaltChainedException

getDependencyNode

public DependencyNode getDependencyNode(int index)
                                 throws MaltChainedException
Description copied from interface: DependencyStructure
Returns the dependency node identified by index if it exists, otherwise null.

Specified by:
getDependencyNode in interface DependencyStructure
Parameters:
index - the index of the dependency node
Returns:
the dependency node identified by index if it exists, otherwise null.
Throws:
MaltChainedException

nDependencyNode

public int nDependencyNode()
Specified by:
nDependencyNode in interface DependencyStructure

getHighestDependencyNodeIndex

public int getHighestDependencyNodeIndex()
Specified by:
getHighestDependencyNodeIndex in interface DependencyStructure

addDependencyEdge

public Edge addDependencyEdge(int headIndex,
                              int dependentIndex)
                       throws MaltChainedException
Description copied from interface: DependencyStructure
Adds an edge from the head to the dependent identified by the indices of the dependency nodes.

Specified by:
addDependencyEdge in interface DependencyStructure
Parameters:
headIndex - the index of the head dependency node
dependentIndex - the index of the dependent dependency node
Returns:
the edge that have been added.
Throws:
MaltChainedException

addDependencyEdge

protected Edge addDependencyEdge(DependencyNode head,
                                 DependencyNode dependent)
                          throws MaltChainedException
Throws:
MaltChainedException

moveDependencyEdge

public Edge moveDependencyEdge(int newHeadIndex,
                               int dependentIndex)
                        throws MaltChainedException
Description copied from interface: DependencyStructure
Replace the head of the dependent with a new head. The labels are not affected.

Specified by:
moveDependencyEdge in interface DependencyStructure
Parameters:
newHeadIndex - the index of the new head dependency node
dependentIndex - the index of the dependent dependency node
Returns:
the edge that have been moved.
Throws:
MaltChainedException

moveDependencyEdge

protected Edge moveDependencyEdge(DependencyNode newHead,
                                  DependencyNode dependent)
                           throws MaltChainedException
Throws:
MaltChainedException

removeDependencyEdge

public void removeDependencyEdge(int headIndex,
                                 int dependentIndex)
                          throws MaltChainedException
Description copied from interface: DependencyStructure
Remove an edge from the head to the dependent identified by the indices of the dependency nodes.

Specified by:
removeDependencyEdge in interface DependencyStructure
Parameters:
headIndex - the index of the head dependency node
dependentIndex - the index of the dependent dependency node
Throws:
MaltChainedException

removeDependencyEdge

protected void removeDependencyEdge(Node head,
                                    Node dependent)
                             throws MaltChainedException
Throws:
MaltChainedException

addSecondaryEdge

public Edge addSecondaryEdge(ComparableNode source,
                             ComparableNode target)
                      throws MaltChainedException
Specified by:
addSecondaryEdge in interface SecEdgeStructure
Throws:
MaltChainedException

removeSecondaryEdge

public void removeSecondaryEdge(ComparableNode source,
                                ComparableNode target)
                         throws MaltChainedException
Specified by:
removeSecondaryEdge in interface SecEdgeStructure
Throws:
MaltChainedException

hasLabeledDependency

public boolean hasLabeledDependency(int index)
                             throws MaltChainedException
Description copied from interface: DependencyStructure
Returns true if the head edge of the dependency node with index is labeled, otherwise false.

Specified by:
hasLabeledDependency in interface DependencyStructure
Parameters:
index - the index of the dependency node
Returns:
true if the head edge of the dependency node with index is labeled, otherwise false.
Throws:
MaltChainedException

isConnected

public boolean isConnected()
Description copied from interface: DependencyStructure
Returns true if all nodes in the dependency structure are connected, otherwise false.

Specified by:
isConnected in interface DependencyStructure
Returns:
true if all nodes in the dependency structure are connected, otherwise false.

isProjective

public boolean isProjective()
                     throws MaltChainedException
Description copied from interface: DependencyStructure
Returns true if all edges in the dependency structure are projective, otherwise false.

Specified by:
isProjective in interface DependencyStructure
Returns:
true if all edges in the dependency structure are projective, otherwise false.
Throws:
MaltChainedException

isTree

public boolean isTree()
Description copied from interface: DependencyStructure
Returns true if the dependency structure are a tree (isConnected() && isSingleHeaded()), otherwise false.

Specified by:
isTree in interface DependencyStructure
Returns:
true if the dependency structure are a tree (isConnected() && isSingleHeaded()), otherwise false.

isSingleHeaded

public boolean isSingleHeaded()
Description copied from interface: DependencyStructure
Returns true if all dependency nodes have at most one incoming edge, otherwise false.

Specified by:
isSingleHeaded in interface DependencyStructure
Returns:
true if all dependency nodes have at most one incoming edge, otherwise false.

isSingleHeadedConstraint

public boolean isSingleHeadedConstraint()

setSingleHeadedConstraint

public void setSingleHeadedConstraint(boolean singleHeadedConstraint)

nNonProjectiveEdges

public int nNonProjectiveEdges()
                        throws MaltChainedException
Description copied from interface: DependencyStructure
Returns the number of non-projective edges in the dependency structure.

Specified by:
nNonProjectiveEdges in interface DependencyStructure
Returns:
the number of non-projective edges in the dependency structure.
Throws:
MaltChainedException

nEdges

public int nEdges()
Description copied from interface: DependencyStructure
Returns the number of edges

Specified by:
nEdges in interface DependencyStructure
Returns:
the number of edges

getEdges

public SortedSet<Edge> getEdges()
Specified by:
getEdges in interface DependencyStructure

getDependencyIndices

public SortedSet<Integer> getDependencyIndices()
Description copied from interface: DependencyStructure
Returns a sorted set of integers {0,s,..n} , where each index i identifies a dependency node. Index 0 should always be the root dependency node and index s is the first terminal node and index n is the last terminal node.

Specified by:
getDependencyIndices in interface DependencyStructure
Returns:
a sorted set of integers

link

protected DependencyNode link(DependencyNode x,
                              DependencyNode y)

linkAllTreesToRoot

public void linkAllTreesToRoot()
                        throws MaltChainedException
Description copied from interface: DependencyStructure
Links all subtrees to the root of the dependency structure.

Specified by:
linkAllTreesToRoot in interface DependencyStructure
Throws:
MaltChainedException

getDefaultRootEdgeLabels

public LabelSet getDefaultRootEdgeLabels()
                                  throws MaltChainedException
Specified by:
getDefaultRootEdgeLabels in interface DependencyStructure
Throws:
MaltChainedException

getDefaultRootEdgeLabelSymbol

public String getDefaultRootEdgeLabelSymbol(SymbolTable table)
                                     throws MaltChainedException
Description copied from interface: DependencyStructure
Returns the default edge label of the root as a string value.

Specified by:
getDefaultRootEdgeLabelSymbol in interface DependencyStructure
Parameters:
table - the symbol table that identifies the label type.
Returns:
the default edge label of the root.
Throws:
MaltChainedException

getDefaultRootEdgeLabelCode

public int getDefaultRootEdgeLabelCode(SymbolTable table)
                                throws MaltChainedException
Description copied from interface: DependencyStructure
Returns the default edge label of the root as an integer value.

Specified by:
getDefaultRootEdgeLabelCode in interface DependencyStructure
Parameters:
table - the symbol table that identifies the label type.
Returns:
the default edge label of the root as an integer value.
Throws:
MaltChainedException

setDefaultRootEdgeLabel

public void setDefaultRootEdgeLabel(SymbolTable table,
                                    String defaultRootSymbol)
                             throws MaltChainedException
Description copied from interface: DependencyStructure
Sets the default edge label of the root.

Specified by:
setDefaultRootEdgeLabel in interface DependencyStructure
Parameters:
table - the symbol table that identifies the label type.
defaultRootSymbol - the default root edge label
Throws:
MaltChainedException

setDefaultRootEdgeLabels

public void setDefaultRootEdgeLabels(String rootLabelOption,
                                     SortedMap<String,SymbolTable> edgeSymbolTables)
                              throws MaltChainedException
Description copied from interface: DependencyStructure
Sets the default edge label of the root according to the default root label option

Specified by:
setDefaultRootEdgeLabels in interface DependencyStructure
Parameters:
rootLabelOption - the default root label option
edgeSymbolTables - a sorted map that maps the symbol table name to the symbol table object.
Throws:
MaltChainedException

clear

public void clear()
           throws MaltChainedException
Description copied from interface: Structure
Resets the structure.

Specified by:
clear in interface Structure
Overrides:
clear in class Sentence
Throws:
MaltChainedException

getDependencyRoot

public DependencyNode getDependencyRoot()
Description copied from interface: DependencyStructure
Returns the root of the dependency structure.

Specified by:
getDependencyRoot in interface DependencyStructure
Returns:
the root of the dependency structure.

toString

public String toString()
Overrides:
toString in class Sentence

MaltParser 1.4.1

Copyright 2007-2010 Johan Hall, Jens Nilsson and Joakim Nivre.