001package org.maltparser.core.syntaxgraph.node;
002
003import java.util.List;
004import java.util.Set;
005import java.util.SortedSet;
006
007import org.maltparser.core.exception.MaltChainedException;
008import org.maltparser.core.symbol.SymbolTable;
009import org.maltparser.core.syntaxgraph.LabelSet;
010import org.maltparser.core.syntaxgraph.edge.Edge;
011
012
013
014public interface DependencyNode extends ComparableNode {
015        /**
016         * Returns <i>true</i> if the node has at most one head, otherwise <i>false</i>.
017         * 
018         * @return <i>true</i> if the node has at most one head, otherwise <i>false</i>.
019         */
020        public boolean hasAtMostOneHead();
021        /**
022         * Returns <i>true</i> if the node has one or more head(s), otherwise <i>false</i>.
023         * 
024         * @return <i>true</i> if the node has one or more head(s), otherwise <i>false</i>.
025         */ 
026        public boolean hasHead();
027        public Set<DependencyNode> getHeads() throws MaltChainedException;
028        public Set<Edge> getHeadEdges() throws MaltChainedException;
029        
030
031        /**
032         * Returns the predecessor dependency node in the linear order of the token nodes.
033         * 
034         * @return the predecessor dependency node in the linear order of the token nodes.
035         */
036        public DependencyNode getPredecessor();
037        /**
038         * Returns the successor dependency node in the linear order of the token nodes.
039         * 
040         * @return the successor dependency node in the linear order of the token nodes.
041         */
042        public DependencyNode getSuccessor();
043        
044        /**
045         * Returns the head dependency node if it exists, otherwise <i>null</i>. If there exists more
046         * than one head the first head is returned according to the linear order of the terminals 
047         * or the root if it is one of the heads.
048         * 
049         * @return the head dependency node if it exists, otherwise <i>null</i>.
050         * @throws MaltChainedException
051         */
052        public DependencyNode getHead() throws MaltChainedException;
053        /**
054         * Returns the edge between the head and the node if it exists, otherwise <i>null</i>. If there exists more
055         * than one head edge the first head edge is returned according to the linear order of the terminals 
056         * or the root if it is one of the heads.
057         * 
058         * @return the edge between the head and the node if it exists, otherwise <i>null</i>.
059         * @throws MaltChainedException
060         */
061        public Edge getHeadEdge() throws MaltChainedException;
062        public boolean hasAncestorInside(int left, int right) throws MaltChainedException;
063        public void addHeadEdgeLabel(SymbolTable table, String symbol) throws MaltChainedException;
064        public void addHeadEdgeLabel(SymbolTable table, int code) throws MaltChainedException;
065        public void addHeadEdgeLabel(LabelSet labelSet) throws MaltChainedException;
066        public boolean hasHeadEdgeLabel(SymbolTable table) throws MaltChainedException;
067        public String getHeadEdgeLabelSymbol(SymbolTable table) throws MaltChainedException;
068        public int getHeadEdgeLabelCode(SymbolTable table) throws MaltChainedException;
069        public boolean isHeadEdgeLabeled() throws MaltChainedException;
070        public int nHeadEdgeLabels() throws MaltChainedException;
071        public Set<SymbolTable> getHeadEdgeLabelTypes() throws MaltChainedException;
072        public LabelSet getHeadEdgeLabelSet() throws MaltChainedException;
073        public DependencyNode getAncestor() throws MaltChainedException;
074        public DependencyNode getProperAncestor() throws MaltChainedException;
075        
076        public boolean hasDependent();
077        /**
078         * Returns <i>true</i> if the node has one or more left dependents, otherwise <i>false</i>.
079         * 
080         * @return <i>true</i> if the node has one or more left dependents, otherwise <i>false</i>.
081         */
082        public boolean hasLeftDependent();
083        /**
084         * Returns the left dependent at the position <i>index</i>, where <i>index==0</i> equals the left most dependent.
085         * 
086         * @param index the index
087         * @return the left dependent at the position <i>index</i>, where <i>index==0</i> equals the left most dependent
088         */
089        public DependencyNode getLeftDependent(int index);
090        /**
091         * Return the number of left dependents
092         * 
093         * @return the number of left dependents
094         */
095        public int getLeftDependentCount();
096        /**
097         * Returns a sorted set of left dependents.
098         * 
099         * @return a sorted set of left dependents.
100         */
101        public SortedSet<DependencyNode> getLeftDependents();
102        /**
103         * Returns the left sibling if it exists, otherwise <code>null</code>
104         * 
105         * @return the left sibling if it exists, otherwise <code>null</code>
106         */
107        public DependencyNode getLeftSibling() throws MaltChainedException;
108        /**
109         * Returns the left sibling at the same side of head as the node it self. If not found <code>null</code> is returned
110         * 
111         * @return the left sibling at the same side of head as the node it self. If not found <code>null</code> is returned
112         */
113        public DependencyNode getSameSideLeftSibling() throws MaltChainedException;
114        /**
115         * Returns the closest left dependent to the node it self, if not found <code>null</code> is returned.
116         * 
117         * @return the closest left dependent to the node it self, if not found <code>null</code> is returned.
118         */
119        public DependencyNode getClosestLeftDependent();
120        public DependencyNode getLeftmostDependent();
121        public DependencyNode getRightDependent(int index);
122        /**
123         * Return the number of right dependents
124         * 
125         * @return the number of right dependents
126         */
127        public int getRightDependentCount();
128        /**
129         * Returns a sorted set of right dependents.
130         * 
131         * @return a sorted set of right dependents.
132         */
133        public SortedSet<DependencyNode> getRightDependents();
134        /**
135         * Returns the right sibling if it exists, otherwise <code>null</code>
136         * 
137         * @return the right sibling if it exists, otherwise <code>null</code>
138         */
139        public DependencyNode getRightSibling() throws MaltChainedException;
140        /**
141         * Returns the right sibling at the same side of head as the node it self. If not found <code>null</code> is returned
142         * 
143         * @return the right sibling at the same side of head as the node it self. If not found <code>null</code> is returned
144         */
145        public DependencyNode getSameSideRightSibling() throws MaltChainedException;
146        /**
147         * Returns the closest right dependent to the node it self, if not found <code>null</code> is returned.
148         * 
149         * @return the closest right dependent to the node it self, if not found <code>null</code> is returned.
150         */
151        public DependencyNode getClosestRightDependent();
152        public DependencyNode getRightmostDependent();
153        public boolean hasRightDependent();
154        
155        public List<DependencyNode> getListOfDependents();
156        public List<DependencyNode> getListOfLeftDependents();
157        public List<DependencyNode> getListOfRightDependents();
158        
159        /**
160         * Returns <i>true</i> if the head edge is projective, otherwise <i>false</i>. Undefined if the node has 
161         * more than one head.
162         * 
163         * @return <i>true</i> if the head edge is projective, otherwise <i>false</i>.
164         * @throws MaltChainedException
165         */
166        public boolean isProjective() throws MaltChainedException;
167        /**
168         * Returns the depth of the node. The root node has the depth 0.
169         * @return the depth of the node.
170         * @throws MaltChainedException
171         */
172        public int getDependencyNodeDepth() throws MaltChainedException;
173        public int getRank();
174        public void setRank(int r);
175        public DependencyNode findComponent();
176        public DependencyNode getComponent();
177        public void setComponent(DependencyNode x);
178}