Examples of DependencyNode


Examples of org.maltparserx.core.syntaxgraph.node.DependencyNode

  }

  private boolean attachCoveredRoots(DependencyStructure pdg, DependencyNode deepest) throws MaltChainedException {
    int i;
    boolean foundCoveredRoot = false;
    DependencyNode coveredRootHead;
    for (i = Math.min(deepest.getIndex(), deepest.getHead().getIndex()) + 1; i < Math.max(deepest.getIndex(), deepest.getHead()
        .getIndex()); i++) {
      int leftMostIndex = pdg.getDependencyNode(i).getLeftmostProperDescendantIndex();
      if (leftMostIndex == -1) {
        leftMostIndex = i;
      }
      int rightMostIndex = pdg.getDependencyNode(i).getRightmostProperDescendantIndex();
      if (rightMostIndex == -1) {
        rightMostIndex = i;
      }
      if (!nodeLifted.get(i) && pdg.getDependencyNode(i).getHead().isRoot() && !deepest.getHead().isRoot()
          && Math.min(deepest.getIndex(), deepest.getHead().getIndex()) < leftMostIndex
          && rightMostIndex < Math.max(deepest.getIndex(), deepest.getHead().getIndex())) {
        if (rootAttachment == CoveredRootAttachment.LEFT) {
          if (deepest.getHead().getIndex() < deepest.getIndex()) {
            coveredRootHead = deepest.getHead();
          } else {
            coveredRootHead = deepest;
          }
        } else if (rootAttachment == CoveredRootAttachment.RIGHT) {
          if (deepest.getIndex() < deepest.getHead().getIndex()) {
            coveredRootHead = deepest.getHead();
          } else {
            coveredRootHead = deepest;
          }
        } else {
          coveredRootHead = deepest.getHead();
        }
        pdg.moveDependencyEdge(coveredRootHead.getIndex(), pdg.getDependencyNode(i).getIndex());
        setCoveredRoot(pdg.getDependencyNode(i));
        foundCoveredRoot = true;
      }
    }
    return foundCoveredRoot;
View Full Code Here

Examples of org.maltparserx.core.syntaxgraph.node.DependencyNode

  private void setCoveredRoot(DependencyNode node) {
    isCoveredRoot.set(node.getIndex(), true);
  }

  private DependencyNode getDeepestNonProjectiveNode(DependencyStructure pdg) throws MaltChainedException {
    DependencyNode deepestNonProjectiveNode = null;
    for (int index : pdg.getDependencyIndices()) {
      if (!pdg.getDependencyNode(index).isProjective()
          && (deepestNonProjectiveNode == null
          || pdg.getDependencyNode(index).getDependencyNodeDepth() > pdg.getDependencyNode(deepestNonProjectiveNode.getIndex()).getDependencyNodeDepth())) {
        deepestNonProjectiveNode = pdg.getDependencyNode(index);
      }
    }
   
    return deepestNonProjectiveNode;
View Full Code Here

Examples of org.maltparserx.core.syntaxgraph.node.DependencyNode

   
    return deepestNonProjectiveNode;
  }

  private DependencyNode getShortestNonProjectiveNode(DependencyStructure pdg) throws MaltChainedException {
    DependencyNode shortestNonProjectiveNode = null;
    for (int index : pdg.getDependencyIndices()) {
      if (!pdg.getDependencyNode(index).isProjective()
          && (shortestNonProjectiveNode == null
          || nodeRelationLength.get(index) < nodeRelationLength.get(shortestNonProjectiveNode.getIndex())
          )) {
//          || (nodeRelationLength.get(index) == nodeRelationLength.get(shortestNonProjectiveNode.getIndex())))) {
        shortestNonProjectiveNode = pdg.getDependencyNode(index);
      }
    }
View Full Code Here

Examples of org.maltparserx.core.syntaxgraph.node.DependencyNode

  // If this is not the case, there is no need to call deprojectivizeWithHead.

  private boolean needsDeprojectivizeWithHead(DependencyStructure pdg) throws MaltChainedException {
    for (int index : pdg.getDependencyIndices()) {
      if (nodeLifted.get(index)) {
        DependencyNode node = pdg.getDependencyNode(index);
        if (breadthFirstSearchSortedByDistanceForHead(pdg, node.getHead(), node, synacticHeadDeprel.get(index)) != null) {
          return true;
        }
        }
    }
    return false;
View Full Code Here

Examples of org.maltparserx.core.syntaxgraph.node.DependencyNode

  }

  private boolean deprojectivizeWithHead(DependencyStructure pdg, DependencyNode node) throws MaltChainedException {
    boolean success = true, childSuccess = false;
    int i, childAttempts = 2;
    DependencyNode child, possibleSyntacticHead;
    String syntacticHeadDeprel;
    if (nodeLifted.get(node.getIndex())) {
      syntacticHeadDeprel = synacticHeadDeprel.get(node.getIndex());
      possibleSyntacticHead = breadthFirstSearchSortedByDistanceForHead(pdg, node.getHead(), node, syntacticHeadDeprel);
      if (possibleSyntacticHead != null) {
View Full Code Here

Examples of org.maltparserx.core.syntaxgraph.node.DependencyNode

    return childSuccess && success;
  }

  private DependencyNode breadthFirstSearchSortedByDistanceForHead(DependencyStructure dg, DependencyNode start, DependencyNode avoid, String syntacticHeadDeprel)
      throws MaltChainedException {
    DependencyNode dependent;
    String dependentDeprel;
    Vector<DependencyNode> nodes = new Vector<DependencyNode>();
    nodes.addAll(findAllDependentsVectorSortedByDistanceToPProjNode(dg, start, avoid, false));
    while (nodes.size() > 0) {
      dependent = nodes.remove(0);
      if (dependent.getHeadEdge().hasLabel(deprelSymbolTable)) {
        dependentDeprel = deprelSymbolTable.getSymbolCodeToString(dependent.getHeadEdge().getLabelCode(deprelSymbolTable));
        if (dependentDeprel.equals(syntacticHeadDeprel)) {
          return dependent;
        }
      }
      nodes.addAll(findAllDependentsVectorSortedByDistanceToPProjNode(dg, dependent, avoid, false));
View Full Code Here

Examples of org.maltparserx.core.syntaxgraph.node.DependencyNode

    }
    if (distances.length > 1) {
      int smallest;
      int n = distances.length;
      int tmpDist;
      DependencyNode tmpDep;
      for (i=0; i < n; i++) {
        smallest = i;
        for (int j=i; j < n; j++) {
          if (distances[j] < distances[smallest]) {
            smallest = j;
View Full Code Here

Examples of org.maltparserx.core.syntaxgraph.node.DependencyNode

 
  private Vector<DependencyNode> findAllDependentsVectorSortedByDistanceToPProjNode2(DependencyStructure dg, DependencyNode governor, DependencyNode avoid,
      boolean percentOnly) {
    int i, j;
    Vector<DependencyNode> dependents = new Vector<DependencyNode>();
    DependencyNode leftChild, rightChild;

    i = governor.getLeftDependentCount() - 1;
    j = 0;
    leftChild = governor.getLeftDependent(i--);
    rightChild = governor.getRightDependent(j++);

    while (leftChild != null && rightChild != null) {
      if (leftChild == avoid) {
        leftChild = governor.getLeftDependent(i--);
      } else if (rightChild == avoid) {
        rightChild = governor.getRightDependent(j++);
      } else if (Math.abs(leftChild.getIndex() - avoid.getIndex()) < Math.abs(rightChild.getIndex() - avoid.getIndex())) {
        if (!percentOnly || (percentOnly && nodePath.get(leftChild.getIndex()))) {
          dependents.add(leftChild);
        }
        leftChild = governor.getLeftDependent(i--);
      } else {
        if (!percentOnly || (percentOnly && nodePath.get(rightChild.getIndex()))) {
          dependents.add(rightChild);
        }
        rightChild = governor.getRightDependent(j++);
      }
    }
    while (leftChild != null) {
      if (leftChild != avoid && (!percentOnly || (percentOnly && nodePath.get(leftChild.getIndex())))) {
        dependents.add(leftChild);
      }
      leftChild = governor.getLeftDependent(i--);
    }
    while (rightChild != null) {
View Full Code Here

Examples of org.maltparserx.core.syntaxgraph.node.DependencyNode

      try {
        writer.append("graph # ");
        writer.append(Integer.toString(graphCounter));
        writer.append('\n');
        for (int index : cachedSource.getTokenIndices()) {
          DependencyNode node = cachedSource.getDependencyNode(index);
         
          writer.append(Integer.toString(node.getIndex()));
          writer.append('\t');
          writer.append(Integer.toString(node.getHead().getIndex()));
          writer.append('\t');
          writer.append('#');
          writer.append('\t');
          if (node.isProjective()) {
            writer.append("@P");
          } else {
            writer.append("@N");
          }
          writer.append('\n');
View Full Code Here

Examples of org.maltparserx.core.syntaxgraph.node.DependencyNode

  }

  private boolean deprojectivizeWithPath(DependencyStructure pdg, DependencyNode node) throws MaltChainedException {
    boolean success = true, childSuccess = false;
    int i, childAttempts = 2;
    DependencyNode child, possibleSyntacticHead;
    if (node.hasHead() && node.getHeadEdge().isLabeled() && nodeLifted.get(node.getIndex()) && nodePath.get(node.getIndex())) {
      possibleSyntacticHead = breadthFirstSearchSortedByDistanceForPath(pdg, node.getHead(), node);
      if (possibleSyntacticHead != null) {
        pdg.moveDependencyEdge(possibleSyntacticHead.getIndex(), node.getIndex());
        nodeLifted.set(node.getIndex(), false);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.