Package org.maltparserx.core.syntaxgraph.edge

Examples of org.maltparserx.core.syntaxgraph.edge.Edge


  {
    TwoPlanarConfig planarConfig = (TwoPlanarConfig)config;
    //DependencyStructure dg = planarConfig.getDependencyGraph(); -> no need, if rightmostLimit is well chosen, due to algorithm invariants
    int inputPeekIndex = planarConfig.getInput().peek().getIndex();
   
    Edge current = null;
    int maxIndex;
    if ( planarConfig.getRootHandling() == TwoPlanarConfig.NORMAL )
      maxIndex = -1; //count links from dummy root
    else
      maxIndex = 0; //do not count links from dummy root
View Full Code Here


    TwoPlanarConfig planarConfig = (TwoPlanarConfig)config;
    Stack<DependencyNode> activeStack = planarConfig.getActiveStack();
    Stack<DependencyNode> inactiveStack = planarConfig.getInactiveStack();
    Stack<DependencyNode> input = planarConfig.getInput();
    currentAction.getAction(actionContainers);
    Edge e = null;
    int actionCode = transActionContainer.getActionCode();
    switch ( actionCode ) {
    case LEFTARC:
      e = planarConfig.getDependencyStructure().addDependencyEdge(input.peek().getIndex(), activeStack.peek().getIndex());
      addEdgeLabels(e);
View Full Code Here

      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.");
    }
View Full Code Here

 
  public Edge moveDependencyEdge(DependencyNode newHead, DependencyNode dependent) throws MaltChainedException {
    if (dependent == null || !dependent.hasHead() || newHead.getBelongsToGraph() != this || dependent.getBelongsToGraph() != this) {
      return null;
    }
    Edge headEdge = dependent.getHeadEdge();

    LabelSet labels = null;
    if (headEdge.isLabeled()) {
      labels = checkOutNewLabelSet();
      for (SymbolTable table : headEdge.getLabelTypes()) {
        labels.put(table, headEdge.getLabelCode(table));
      }
    }
    headEdge.clear();
    headEdge.setBelongsToGraph(this);
    headEdge.setEdge((Node)newHead, (Node)dependent, Edge.DEPENDENCY_EDGE);
    if (labels != null) {
      headEdge.addLabel(labels);
      labels.clear();
      checkInLabelSet(labels);
    }
    return headEdge;
  }
View Full Code Here

    if (head == null || dependent == null || head.getBelongsToGraph() != this || dependent.getBelongsToGraph() != this) {
      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) {
          ie.remove();
          graphEdges.remove(e);
          edgePool.checkIn(e);
        }
      }
View Full Code Here

  public Edge addSecondaryEdge(ComparableNode source, ComparableNode target) throws MaltChainedException {
    if (source == null || target == null || source.getBelongsToGraph() != this || target.getBelongsToGraph() != this) {
      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;
  }
View Full Code Here

    if (source == null || target == null || source.getBelongsToGraph() != this || target.getBelongsToGraph() != this) {
      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);
        }
      }
View Full Code Here

  }
 
  public void linkAllTreesToRoot() throws MaltChainedException {
    for (int i : terminalNodes.keySet()) {
      if (!terminalNodes.get(i).hasHead()) {
        Edge e = addDependencyEdge(root,terminalNodes.get(i));
        mapping.updatePhraseStructureGraph(this, e, false);
      }
    }
  }
View Full Code Here

    } else if (parent.getBelongsToGraph() != this || child.getBelongsToGraph() != this) {
      throw new MaltChainedException("Parent or child node is not a member of the graph in sentence "+getSentenceID());
    } else if (parent == child) {
      throw new MaltChainedException("It is not allowed to add a phrase structure edge connecting the same node in sentence "+getSentenceID());
    } else if (parent instanceof NonTerminalNode && !child.isRoot()) {
      Edge e = edgePool.checkOut();
      e.setBelongsToGraph(this);
      e.setEdge((Node)parent, (Node)child, Edge.PHRASE_STRUCTURE_EDGE);
      graphEdges.add(e);
      return e;
    } else {
      throw new MaltChainedException("Parent or child node is not of correct node type.");
    }
View Full Code Here

    sb.append(node.toString().trim());
    sb.append('\n');
    Iterator<Edge> ie = ((Node)node).getOutgoingEdgeIterator();
    while (ie.hasNext()) {
      Edge e = ie.next();
      if (e.getTarget() instanceof TokenNode) {
        sb.append("   T");
        sb.append(e.getTarget().getIndex());
      }
      if (e.getTarget() instanceof NonTerminalNode) {
        sb.append("   N");
        sb.append(e.getTarget().getIndex());
      }
      sb.append('\t');
      sb.append(e.toString());
      sb.append('\n');
    }
    return sb.toString();
  }
View Full Code Here

TOP

Related Classes of org.maltparserx.core.syntaxgraph.edge.Edge

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.