Ejemplo n.º 1
0
  /** Resets dependents of each node in this tree. */
  public void resetDependents() {
    int i, size = size();
    DEPNode node, head;

    for (i = 0; i < size; i++) get(i).l_dependents = new ArrayList<DEPArc>();

    for (i = 1; i < size; i++) {
      node = get(i);
      head = node.getHead();

      if (head != null) head.addDependent(node, node.getLabel());
    }
  }
Ejemplo n.º 2
0
  public DEPTree clone() {
    IntObjectOpenHashMap<DEPNode> map = new IntObjectOpenHashMap<DEPNode>();
    DEPNode oNode, nNode, oHead, nHead;
    DEPTree tree = new DEPTree();
    int i, size = size();

    for (i = 1; i < size; i++) {
      oNode = get(i);
      nNode = new DEPNode(oNode);
      tree.add(nNode);
      nNode.id = i;
      map.put(oNode.id, nNode);

      if (oNode.x_heads != null) nNode.initXHeads();

      if (oNode.s_heads != null) nNode.initSHeads();
    }

    for (i = 1; i < size; i++) {
      oNode = get(i);
      nNode = tree.get(i);
      oHead = oNode.getHead();
      nHead = map.get(oHead.id);

      if (nHead == null) {
        nHead = tree.get(0);
      } else {
        if (oNode.x_heads != null) {
          for (DEPArc xHead : oNode.x_heads) {
            oHead = xHead.getNode();
            nNode.addXHead(map.get(oHead.id), xHead.getLabel());
          }
        }

        if (oNode.s_heads != null) {
          for (DEPArc sHead : oNode.s_heads) {
            oHead = sHead.getNode();
            nNode.addSHead(map.get(oHead.id), sHead.getLabel());
          }
        }
      }

      nNode.setHead(nHead, oNode.getLabel());
    }

    return tree;
  }
Ejemplo n.º 3
0
  public StringIntPair[] getDiff(StringIntPair[] heads) {
    int i, size = size();
    DEPNode node, head;

    StringIntPair[] diff = new StringIntPair[size];
    StringIntPair p;

    for (i = 1; i < size; i++) {
      node = get(i);
      head = node.getHead();
      p = heads[i];

      if (head != null && head.id != p.i && !node.isLabel(p.s))
        diff[i] = new StringIntPair(node.getLabel(), head.id);
      else diff[i] = new StringIntPair(null, DEPLib.NULL_ID);
    }

    return diff;
  }