Package com.clearnlp.dependency

Examples of com.clearnlp.dependency.DEPArc


      return false;

    List<DEPArc> deps = verb.getDependents();
    int i, size = deps.size();
    DEPNode node;
    DEPArc  dep;
   
    for (i=0; i<size; i++)
    {
      dep  = deps.get(i);
      node = dep.getNode();
     
      if (node.id < verb.id)
      {
        if (dep.isLabel(DEPLibEn.DEP_COMPLM) || dep.isLabel(DEPLibEn.DEP_MARK))
          return false;
       
        if (dep.isLabel(P_AUX) && !node.isLemma("do"))
          return false;
       
        if (node.isPos(CTLibEn.POS_TO) || node.isPos(CTLibEn.POS_MD) || node.pos.startsWith("W"))
          return false
      }
     
      if (dep.isLabel(P_SBJ) || dep.isLabel(DEPLibEn.DEP_EXPL))
        return false;
    }
   
    return true;
  }
View Full Code Here


    Pattern pSbj = Pattern.compile("^[nc]subj.*");
    Pattern pAux = Pattern.compile("^aux.*");
    List<DEPArc> deps = verb.getDependents();
    int i, size = deps.size();
    boolean hasAux = false;
    DEPArc  curr, prev;
    String  label;
    DEPNode node;
   
    for (i=size-1; i>=0; i--)
    {
      curr  = deps.get(i);
      node  = curr.getNode();
      label = curr.getLabel();
     
      if (curr.isLabel(DEPLibEn.DEP_PUNCT))
      {
        if (pPeriod.matcher(node.lemma).find())
          return;
      }
    }
   
    for (i=0; i<size; i++)
    {
      curr  = deps.get(i);
      node  = curr.getNode();
      label = curr.getLabel();
     
      if (node.id > verb.id)
        break;
     
      if (pAux.matcher(label).find())
View Full Code Here

      return false;

    List<DEPArc> deps = verb.getDependents();
    int i, size = deps.size();
    DEPNode node;
    DEPArc  dep;
   
    for (i=0; i<size; i++)
    {
      dep  = deps.get(i);
      node = dep.getNode();
     
      if (node.id < verb.id)
      {
        if (dep.isLabel(DEPLibEn.DEP_COMPLM) || dep.isLabel(DEPLibEn.DEP_MARK))
          return false;
       
        if (dep.isLabel(P_AUX) && !node.isLemma("do"))
          return false;
       
        if (node.isPos(CTLibEn.POS_TO) || node.isPos(CTLibEn.POS_MD) || node.pos.startsWith("W"))
          return false
      }
     
      if (dep.isLabel(P_SBJ) || dep.isLabel(DEPLibEn.DEP_EXPL))
        return false;
    }
   
    return true;
  }
View Full Code Here

    Pattern pSbj = Pattern.compile("^[nc]subj.*");
    Pattern pAux = Pattern.compile("^aux.*");
    List<DEPArc> deps = verb.getDependents();
    int i, size = deps.size();
    boolean hasAux = false;
    DEPArc  curr, prev;
    String  label;
    DEPNode node;
   
    for (i=size-1; i>=0; i--)
    {
      curr  = deps.get(i);
      node  = curr.getNode();
      label = curr.getLabel();
     
      if (curr.isLabel(DEPLibEn.DEP_PUNCT))
      {
        if (pPeriod.matcher(node.lemma).find())
          return;
      }
    }
   
    for (i=0; i<size; i++)
    {
      curr  = deps.get(i);
      node  = curr.getNode();
      label = curr.getLabel();
     
      if (node.id > verb.id)
        break;
     
      if (pAux.matcher(label).find())
View Full Code Here

    List<DEPArc> args;
    PBRoleset roleset;
    String label, n;
    DEPNode node;
    int i, size;
    DEPArc arg;
   
    while ((pred = tree.getNextPredicate(pred.id)) != null)
    {
      args = argLists.get(pred.id);
      size = args.size();
     
      for (i=0; i<size; i++)
      {
        arg   = args.get(i);
        label = arg.getLabel();
       
        if (SRLLib.P_ARG_REF.matcher(label).find())
        {
          if ((n = PBLib.getNumber(label)) != null && !containsNumberedArugment(args, n, 0, i) && containsNumberedArugment(args, n, i+1, size))
          {
            roleset = m_frames.getRoleset(getPBType(pred), pred.lemma, pred.getFeat(DEPLibEn.FEAT_PB));
            n = Integer.toString(Integer.parseInt(n)+1);
           
            if (roleset.isValidArgumentNumber(n) && !containsNumberedArugment(args, n, i+1, size))
            {
              node = arg.getNode();
              node.getSHead(pred).setLabel(SRLLib.PREFIX_REFERENT+"A"+n);
            }
          }
         
          break;
View Full Code Here

    }
  }
 
  private boolean containsNumberedArugment(List<DEPArc> arguments, String n, int bIdx, int eIdx)
  {
    DEPArc arg;
    int i;
   
    for (i=bIdx; i<eIdx; i++)
    {
      arg = arguments.get(i);
     
      if (n.equals(PBLib.getNumber(arg.getLabel())))
        return true;
    }
   
    return false;
  }
View Full Code Here

  protected void initArcs(DEPTree tree)
  {
    int i, j, len, size = tree.size();
    DEPNode curr, prev, next;
    List<DEPArc> deps;
    DEPArc lmd, rmd;
   
    lm_deps = new DEPNode[size];
    rm_deps = new DEPNode[size];
    ln_sibs = new DEPNode[size];
    rn_sibs = new DEPNode[size];
   
    d_tree.setDependents();
   
    for (i=1; i<size; i++)
    {
      deps = d_tree.get(i).getDependents();
      if (deps.isEmpty())  continue;
     
      len = deps.size();
      lmd = deps.get(0);
      rmd = deps.get(len-1);
     
      if (lmd.getNode().id < ilm_deps[i] = lmd.getNode();
      if (rmd.getNode().id > irm_deps[i] = rmd.getNode();
     
      for (j=1; j<len; j++)
      {
        curr = deps.get().getNode();
View Full Code Here

      node = tree.get(i);
     
      for (DEPArc arc : node.getSHeads())
      {
        args = list.get(arc.getNode().id);
        args.add(new DEPArc(node, arc.getLabel()));
      }
    }
   
    return list;
  }
View Full Code Here

  }

  static public void relinkRelativeClause(SRLTree sTree)
  {
    DEPNode pred = sTree.getPredicate();
    DEPArc ref = null;
    DEPNode dep, arg;
   
    for (DEPArc arc : pred.getDependents())
    {
      dep = arc.getNode();
     
      if (dep.containsSHead(pred, P_ARG_REF))
      {
        ref = arc;
        break;
      }
    }
   
    for (SRLArc sArc : sTree.getArguments())
    {
      arg = sArc.getNode();
     
      for (DEPArc dArc : arg.getDependents())
      {
        dep = dArc.getNode();
       
        if (dep == pred || pred.isDescendentOf(dep))
        {
          arg.removeDependent(dArc);
          dep.setHead(arg.getHead(), arg.getLabel());
         
          if (ref != null) // && ref.isLabel(SRLLib.S_PREFIX_REFERENT+arg.getLabel())
          {
            DEPNode rDep = ref.getNode();
            DEPArc rHead = rDep.getSHead(pred);
            DEPArc whose = rDep.getAnyDescendentArcByPOS(CTLibEn.POS_WPS);
           
            if (whose != null)
            {
              DEPNode tmp = whose.getNode();
              arg.setHead(tmp.getHead(), tmp.getLabel());
              arg.id = tmp.id;
              whose.setNode(arg);
              rHead.setLabel(sArc.getLabel());
              arg.removeSHead(pred);
             
              tmp = arg.getLastNode();
              tmp.form = LGLibEn.getPossessiveForm(tmp.form);
            }
            else if (ref.isLabel(DEPLibEn.DEP_PREP))
            {
              DEPArc tmp = new DEPArc(arg, DEPLibEn.DEP_POBJ);
             
              arg.setHead(rDep, tmp.getLabel());
              arg.id = rDep.id + 1;
              rDep.clearDependents();
              rDep.addDependent(tmp);
              rHead.setLabel(sArc.getLabel());
              arg.removeSHead(pred);
            }
            else if (ref.isLabel(DEPLibEn.P_SBJ))
            {
              arg.setHead(pred, ref.getLabel());
              arg.id = rDep.id;
              ref.setNode(arg);
              rHead.setLabel(sArc.getLabel());
            }
            else
            {
              DEPArc tmp = new DEPArc(arg, ref.getLabel());
              arg.setHead(pred, tmp.getLabel());
              arg.id = pred.id + 1;
             
              if (ref.isLabel(DEPLibEn.P_OBJ) || ref.isLabel(DEPLibEn.DEP_ATTR))
                pred.addDependentRightNextToSelf(tmp);
              else
                pred.addDependent(tmp);
             
              pred.removeDependent(ref);
            }
          }
          else
          {
            DEPArc tmp = new DEPArc(arg, DEPLibEn.DEP_DEP);
            arg.setHead(pred, tmp.getLabel());
            arg.id = pred.id + 1;
           
            if (sArc.isLabel(PBLib.P_ARGN))
              pred.addDependentRightNextToSelf(tmp);
            else
View Full Code Here

    DEPNode pred = sTree.getPredicate();
    boolean noSbj = pred.getDependentsByLabels(DEPLibEn.P_SBJ).isEmpty();
    Deque<DEPNode> conjuncts;
    List<DEPArc> arcs;
    DEPNode conj, dep;
    DEPArc sArc;
 
    conjuncts = DEPLibEn.getPreviousConjuncts(pred);
   
    if (!conjuncts.isEmpty())
    {
      conj = conjuncts.getLast();
      arcs = conj.getDependents();
     
      int i; for (i=arcs.size()-1; i>=0; i--)
      {
        dep = arcs.get(i).getNode();
        sArc = dep.getSHead(pred);
       
        if (noSbj && (dep.isLabel(DEPLibEn.P_SBJ) || dep.isLabel(DEPLibEn.P_AUX)) || (sArc != null && sArc.isLabel(ARGM_NEG)))
        {
          dep.setHead(pred);
          pred.addDependentFront(new DEPArc(dep, dep.getLabel()));
        }
        else if (dep.containsSHead(pred))
        {
          dep.setHead(pred);
          dep.id = pred.id+1;
          pred.addDependent(new DEPArc(dep, dep.getLabel()));
        }
      }
    }
   
    conjuncts = DEPLibEn.getNextConjuncts(pred);
   
    if (!conjuncts.isEmpty())
    {
      conj = conjuncts.getLast();
     
      for (DEPArc arc : conj.getDependents())
      {
        dep = arc.getNode();
       
        if (dep.containsSHead(pred))
        {
          dep.setHead(pred);
          pred.addDependent(new DEPArc(dep, dep.getLabel()));
        }
      }
    }
  }
View Full Code Here

TOP

Related Classes of com.clearnlp.dependency.DEPArc

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.