Package com.clearnlp.dependency

Examples of com.clearnlp.dependency.DEPNode


  }
 
  protected List<StringInstance> parseOne(DEPState state)
  {
    List<StringInstance> insts = Lists.newArrayList();
    DEPNode  lambda, beta;
    DEPLabel label;
   
    while (state.isBetaValid())
    {
      if (!state.isLambdaValid())
View Full Code Here


    return insts;
  }
 
  protected void parseAux(DEPLabel label, DEPState state)
  {
    DEPNode lambda = state.getLambda();
    DEPNode beta   = state.getBeta();
   
    state.increaseTransitionCount();
    state.addScore(label.score);
   
    if (label.isArc(LB_LEFT))
    {
      if (lambda.id == DEPLib.ROOT_ID)
        state.shift();
      else if (beta.isDescendentOf(lambda))
        state.pass();
      else
      {
        leftArc(lambda, beta, label.deprel);
View Full Code Here

//  ====================================== PROCESS HEADLESS ======================================
 
  protected void processHeadless(DEPState state)
  {
    Triple<DEPNode,String,Double> max = new Triple<DEPNode,String,Double>(null, null, -1d);
    DEPNode root = state.getNode(DEPLib.ROOT_ID);
    int i, size = state.getTreeSize();
    List<DEPHead> list;
    DEPNode node, head;
   
    for (i=1; i<size; i++)
    {
      node = state.getNode(i);
     
      if (!node.hasHead())
      {
        if (!(list = state.get2ndHeads(node.id)).isEmpty())
        {
          for (DEPHead p : list)
          {
            head = state.getNode(p.headId);
           
            if (!isNotHead(head) && !head.isDescendentOf(node))
            {
              node.setHead(head, p.deprel);
              break;
            }
          }
        }
       
        if (!node.hasHead())
        {
          max.set(root, DEPLibEn.DEP_ROOT, -1d);
         
          processHeadlessAux(node, -1, max, state);
          processHeadlessAux(node, +1, max, state);
         
          node.setHead(max.o1, max.o2);
        }
      }
    }
  }
View Full Code Here

  protected void processHeadlessAux(DEPNode node, int dir, Triple<DEPNode,String,Double> max, DEPState state)
  {
    int i, size = state.getTreeSize();
    List<StringPrediction> ps;
    DEPLabel label;
    DEPNode  head;
   
    if (dir < 0state.setBeta(node.id);
    else      state.setLambda(node.id);
   
    for (i=node.id+dir; 0<=i && i<size; i+=dir)
    {
      head = state.getNode(i);     
      if (head.isDescendentOf(node))  continue;
     
      if (dir < 0state.setLambda(i);
      else      state.setBeta(i);
     
      ps = getPredictions(getFeatureVector(f_xmls[0], state), state);
View Full Code Here

//  ================================ FEATURE EXTRACTION ================================

  @Override
  protected String getField(FtrToken token, DEPState state)
  {
    DEPNode node = state.getNode(token);
    if (node == nullreturn null;
    Matcher m;
   
    if (token.isField(JointFtrXml.F_FORM))
    {
      return node.form;
    }
    else if (token.isField(JointFtrXml.F_SIMPLIFIED_FORM))
    {
      return node.simplifiedForm;
    }
    else if (token.isField(JointFtrXml.F_LEMMA))
    {
      return node.lemma;
    }
    else if (token.isField(JointFtrXml.F_POS))
    {
      return node.pos;
    }
    else if (token.isField(JointFtrXml.F_DEPREL))
    {
      return node.getLabel();
    }
    else if (token.isField(JointFtrXml.F_DISTANCE))
    {
      int dist = state.getDistance();
      return (dist > 6) ? "6" : Integer.toString(dist);
    }
    else if (token.isField(JointFtrXml.F_LEFT_VALENCY))
    {
      return state.getLeftValency(node.id);
    }
    else if (token.isField(JointFtrXml.F_RIGHT_VALENCY))
    {
      return state.getRightValency(node.id);
    }
    else if ((m = JointFtrXml.P_BOOLEAN.matcher(token.field)).find())
    {
      int field = Integer.parseInt(m.group(1));
     
      switch (field)
      {
      case  0: return state.isLambdaFirst() ? token.field : null;
      case  1: return state.isBetaLast() ? token.field : null;
      case  2: return state.isLambdaBetaAdjacent() ? token.field : null;
      default: throw new IllegalArgumentException("Unsupported feature: "+field);
      }
    }
    else if ((m = JointFtrXml.P_FEAT.matcher(token.field)).find())
    {
      return node.getFeat(m.group(1));
    }
   
    return null;
  }
View Full Code Here

  {
    DEPTree tree = new DEPTree();
    int i, size = tokens.size();
   
    for (i=0; i<size; i++)
      tree.add(new DEPNode(i+1, tokens.get(i)));
   
    return tree;
  }
View Full Code Here

    count[1] += size - 1;
  }
 
  private boolean isConstDEP(DEPTree tree, int currId)
  {
    DEPNode curr = tree.get(currId);
    DEPNode head = curr.getHead();
    DEPNode node;
   
    if (curr.id > head.idreturn false;
    int i;
   
    for (i=curr.id+1; i<head.id; i++)
    {
      node = tree.get(i);
     
      if (!node.isDependentOf(head))
        return false;
    }
   
    return true;
  }
View Full Code Here

  void generation(String[] args)
  {
    Pattern ignore = Pattern.compile("AM-MOD|AM-ADV|C-.+|R-.+");
    DEPTree tree = new DEPTree();
   
    tree.add(new DEPNode(1, "Tell"   , "tell" , "VB" , new DEPFeat()));
    tree.add(new DEPNode(2, "me"     , "me"   , "PRP", new DEPFeat()));
    tree.add(new DEPNode(3, "about"  , "about", "IN" , new DEPFeat()));
    tree.add(new DEPNode(4, "berries", "berry", "NNS", new DEPFeat()));

    tree.get(1).setHead(tree.get(0), DEPLibEn.DEP_ROOT);
    tree.get(2).setHead(tree.get(1), DEPLibEn.DEP_DOBJ);
    tree.get(3).setHead(tree.get(1), DEPLibEn.DEP_PREP);
    tree.get(4).setHead(tree.get(3), DEPLibEn.DEP_POBJ);
View Full Code Here

 
  void findNonHeadsAux(DEPTree tree, Prob2DMap map)
  {
    int i, size = tree.size();
    tree.setDependents();
    DEPNode node;
    String yn;
   
    for (i=1; i<size; i++)
    {
      node = tree.get(i);
      yn = node.getDependentNodeList().isEmpty() ? "N" : "Y";
      map.add(node.getLabel(), yn);
    }
  }
View Full Code Here

  }
 
  void extractVerbPPAux(DEPTree tree, Prob2DMap map)
  {
    int i, size = tree.size();
    DEPNode verb;
    SRLArc arc;
   
    tree.setDependents();
   
    for (i=1; i<size; i++)
    {
      verb = tree.get(i);
     
      if (MPLibEn.isVerb(verb.pos))
      {
        for (DEPNode arg : verb.getDependentNodeList())
        {
          if (!arg.isLabel(DEPLibEn.DEP_AGENT) && (arc = arg.getSHead(verb)) != null)
          {
            if (arg.isPos(CTLibEn.POS_IN) && PBLib.isCoreNumberedArgument(arc.getLabel()))
              map.add(verb.lemma, arg.lemma);
View Full Code Here

TOP

Related Classes of com.clearnlp.dependency.DEPNode

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.