示例#1
0
 public Edge addSecondaryEdge(ComparableNode source, ComparableNode target)
     throws MaltChainedException {
   if (source == null || target == null) {
     throw new SyntaxGraphException("Head or dependent node is missing.");
   } else if (!target.isRoot()) {
     Edge e = edgePool.checkOut();
     e.setBelongsToGraph(this);
     e.setEdge((Node) source, (Node) target, Edge.SECONDARY_EDGE);
     graphEdges.add(e);
     return e;
   }
   return null;
 }
示例#2
0
 protected Edge addDependencyEdge(DependencyNode head, DependencyNode dependent)
     throws MaltChainedException {
   if (head == null || dependent == null) {
     throw new SyntaxGraphException("Head or dependent node is missing.");
   } else if (!dependent.isRoot()) {
     if (singleHeadedConstraint && dependent.hasHead()) {
       return moveDependencyEdge(head, dependent);
     }
     DependencyNode hc = ((DependencyNode) head).findComponent();
     DependencyNode dc = ((DependencyNode) dependent).findComponent();
     if (hc != dc) {
       link(hc, dc);
       numberOfComponents--;
     }
     Edge e = edgePool.checkOut();
     e.setBelongsToGraph(this);
     e.setEdge((Node) head, (Node) dependent, Edge.DEPENDENCY_EDGE);
     graphEdges.add(e);
     return e;
   } else {
     throw new SyntaxGraphException("Head node is not a root node or a terminal node.");
   }
 }