예제 #1
0
 public void clear() throws MaltChainedException {
   edgePool.checkInAll();
   graphEdges.clear();
   root.clear();
   super.clear();
   numberOfComponents++;
 }
예제 #2
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;
 }
예제 #3
0
 public void removeSecondaryEdge(ComparableNode source, ComparableNode target)
     throws MaltChainedException {
   if (source == null || target == null) {
     throw new SyntaxGraphException("Head or dependent node is missing.");
   } else if (!target.isRoot()) {
     Iterator<Edge> ie = ((Node) target).getIncomingEdgeIterator();
     while (ie.hasNext()) {
       Edge e = ie.next();
       if (e.getSource() == source) {
         ie.remove();
         graphEdges.remove(e);
         edgePool.checkIn(e);
       }
     }
   }
 }
예제 #4
0
  protected void removeDependencyEdge(Node head, Node dependent) throws MaltChainedException {
    if (head == null || dependent == null) {
      throw new SyntaxGraphException("Head or dependent node is missing.");
    } else if (!dependent.isRoot()) {
      Iterator<Edge> ie = dependent.getIncomingEdgeIterator();

      while (ie.hasNext()) {
        Edge e = ie.next();
        if (e.getSource() == head) {
          graphEdges.remove(e);
          ie.remove();
          edgePool.checkIn(e);
        }
      }
    } else {
      throw new SyntaxGraphException("Head node is not a root node or a terminal node.");
    }
  }
예제 #5
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.");
   }
 }