001package org.maltparser.core.syntaxgraph;
002
003import java.util.SortedMap;
004import java.util.SortedSet;
005
006import org.maltparser.core.exception.MaltChainedException;
007import org.maltparser.core.symbol.SymbolTable;
008import org.maltparser.core.syntaxgraph.edge.Edge;
009import org.maltparser.core.syntaxgraph.node.DependencyNode;
010/**
011*
012*
013* @author Johan Hall
014*/
015public interface DependencyStructure extends TokenStructure, SecEdgeStructure {
016        public DependencyNode addDependencyNode() throws MaltChainedException;
017        public DependencyNode addDependencyNode(int index) throws MaltChainedException;
018        /**
019         * Returns the dependency node identified by <i>index</i> if it exists, otherwise <i>null</i>.
020         * 
021         * @param index the index of the dependency node
022         * @return the dependency node identified by <i>index</i> if it exists, otherwise <i>null</i>.
023         * @throws MaltChainedException
024         */
025        public DependencyNode getDependencyNode(int index) throws MaltChainedException;
026        public int nDependencyNode();
027
028
029        public int getHighestDependencyNodeIndex();
030        /**
031         * Adds an edge from the head to the dependent identified by the indices of the dependency nodes.
032         * 
033         * @param headIndex the index of the head dependency node
034         * @param dependentIndex the index of the dependent dependency node
035         * @return the edge that have been added.
036         * @throws MaltChainedException
037         */
038        public Edge addDependencyEdge(int headIndex, int dependentIndex) throws MaltChainedException;
039        /**
040         * Replace the head of the dependent with a new head. The labels are not affected.
041         * 
042         * @param newHeadIndex the index of the new head dependency node
043         * @param dependentIndex the index of the dependent dependency node
044         * @return the edge that have been moved.
045         * @throws MaltChainedException
046         */
047        public Edge moveDependencyEdge(int newHeadIndex, int dependentIndex) throws MaltChainedException;
048        /**
049         * Remove an edge from the head to the dependent identified by the indices of the dependency nodes.
050         * @param headIndex the index of the head dependency node
051         * @param dependentIndex the index of the dependent dependency node
052         * @throws MaltChainedException
053         */
054        public void removeDependencyEdge(int headIndex, int dependentIndex) throws MaltChainedException;
055        /**
056         * Returns the number of edges
057         * 
058         * @return  the number of edges
059         */
060        public int nEdges();
061        public SortedSet<Edge> getEdges();
062        /**
063         * Returns a sorted set of integers {0,s,..n} , where each index i identifies a dependency node. Index 0
064         * should always be the root dependency node and index s is the first terminal node and index n is the
065         * last terminal node.  
066         * 
067         * @return a sorted set of integers
068         */
069        public SortedSet<Integer> getDependencyIndices();
070        /**
071         * Returns the root of the dependency structure.
072         * 
073         * @return the root of the dependency structure.
074         */
075        public DependencyNode getDependencyRoot();
076        /**
077         * Returns <i>true</i> if the head edge of the dependency node with <i>index</i> is labeled, otherwise <i>false</i>.
078         * 
079         * @param index the index of the dependency node
080         * @return <i>true</i> if the head edge of the dependency node with <i>index</i> is labeled, otherwise <i>false</i>.
081         * @throws MaltChainedException
082         */
083        public boolean hasLabeledDependency(int index) throws MaltChainedException;
084        /**
085         * Returns <i>true</i> if all nodes in the dependency structure are connected, otherwise <i>false</i>.
086         * 
087         * @return <i>true</i> if all nodes in the dependency structure are connected, otherwise <i>false</i>.
088         */
089        public boolean isConnected();
090        /**
091         * Returns <i>true</i> if all edges in the dependency structure are projective, otherwise <i>false</i>.
092         * 
093         * @return <i>true</i> if all edges in the dependency structure are projective, otherwise <i>false</i>.
094         * @throws MaltChainedException
095         */
096        public boolean isProjective() throws MaltChainedException;
097        /**
098         * Returns <i>true</i> if all dependency nodes have at most one incoming edge, otherwise <i>false</i>.
099         * 
100         * @return  <i>true</i> if all dependency nodes have at most one incoming edge, otherwise <i>false</i>.
101         */
102        public boolean isSingleHeaded();
103        /**
104         * Returns <i>true</i> if the dependency structure are a tree (isConnected() && isSingleHeaded()), otherwise <i>false</i>.
105         * 
106         * @return <i>true</i> if the dependency structure are a tree (isConnected() && isSingleHeaded()), otherwise <i>false</i>.
107         */ 
108        public boolean isTree();
109        /**
110         * Returns the number of non-projective edges in the dependency structure.
111         * 
112         * @return the number of non-projective edges in the dependency structure.
113         * @throws MaltChainedException
114         */
115        public int nNonProjectiveEdges() throws MaltChainedException;
116        /**
117         * Links all subtrees to the root of the dependency structure.
118         * 
119         * @throws MaltChainedException
120         */
121        public void linkAllTreesToRoot() throws MaltChainedException;
122        
123        
124        public LabelSet getDefaultRootEdgeLabels() throws MaltChainedException;
125        /**
126         * Returns the default edge label of the root as a string value.
127         * 
128         * @param table the symbol table that identifies the label type.
129         * @return the default edge label of the root.
130         * @throws MaltChainedException
131         */
132        public String getDefaultRootEdgeLabelSymbol(SymbolTable table) throws MaltChainedException;
133        /**
134         * Returns the default edge label of the root as an integer value.
135         * 
136         * @param table the symbol table that identifies the label type.
137         * @return the default edge label of the root as an integer value.
138         * @throws MaltChainedException
139         */
140        public int getDefaultRootEdgeLabelCode(SymbolTable table) throws MaltChainedException;
141        /**
142         * Sets the default edge label of the root.
143         * 
144         * @param table the symbol table that identifies the label type.
145         * @param defaultRootSymbol the default root edge label
146         * @throws MaltChainedException
147         */
148        public void setDefaultRootEdgeLabel(SymbolTable table, String defaultRootSymbol) throws MaltChainedException;
149        /**
150         * Sets the default edge label of the root according to the default root label option
151         * 
152         * @param rootLabelOption the default root label option
153         * @param edgeSymbolTables a sorted map that maps the symbol table name to the symbol table object.
154         * @throws MaltChainedException
155         */
156        public void setDefaultRootEdgeLabels(String rootLabelOption, SortedMap<String, SymbolTable> edgeSymbolTables) throws MaltChainedException;
157}