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