Package com.clearnlp.dependency

Examples of com.clearnlp.dependency.DEPNode


  private String getSubcat(DEPNode node, String type, int dir)
  {
    List<DEPArc>  deps  = node.getDependents();
    StringBuilder build = new StringBuilder();
    int i, size = deps.size();
    DEPNode dep;
   
    if (dir == SUBCAT_LEFT)
    {
      for (i=0; i<size; i++)
      {
View Full Code Here


    return ps.get(0);
  }
 
  protected void rerankPredictions(List<StringPrediction> ps, SRLState state)
  {
    DEPNode arg = state.getCurrentArgument();
    boolean change = false;
   
    for (StringPrediction p : ps)
    {
      if (rerankFrameMismatch(p, state) || rerankRedundantNumberedArgument(p, state) || rerankFromArgument(p, arg))
View Full Code Here

  @Override
  protected void rerankPredictions(List<StringPrediction> ps, DEPState state)
  {
    if (!isDecode()) return;
   
    DEPNode lambda = state.getLambda();
    DEPNode beta   = state.getBeta();
   
    int i, size = ps.size(), count = 0;
    boolean lChanged, gChanged = false;
    StringPrediction prediction;
    DEPLabel label;
View Full Code Here

 
  private boolean rerankUnique(StringPrediction prediction, DEPLabel label, DEPNode head, Pattern p, int bIdx, int eIdx, DEPState state)
  {
    if (p.matcher(label.deprel).find())
    {
      DEPNode node;
      int i;
     
      for (i=bIdx; i<eIdx; i++)
      {
        node = state.getNode(i);
       
        if (node.isDependentOf(head) && p.matcher(node.getLabel()).find())
        {
          prediction.score = -1;
          return true;
        }
      }
View Full Code Here

 
//  ====================================== NODES ======================================
 
  public DEPNode getNode(FtrToken token)
  {
    DEPNode node = null;
   
    switch (token.source)
    {
    case JointFtrXml.S_STACK : node = getNodeStack(token)break;
    case JointFtrXml.S_LAMBDA: node = getNode(token, i_lambda, 0, i_beta)break;
    case JointFtrXml.S_BETA  : node = getNode(token, i_beta, i_lambda, t_size)break;
    }
   
    if (node == nullreturn null;
   
    if (token.relation != null)
    {
           if (token.isRelation(JointFtrXml.R_H))    node = node.getHead();
      else if (token.isRelation(JointFtrXml.R_H2))  node = node.getGrandHead();
      else if (token.isRelation(JointFtrXml.R_LMD))  node = d_tree.getLeftMostDependent  (node.id);
      else if (token.isRelation(JointFtrXml.R_RMD))  node = d_tree.getRightMostDependent (node.id);
      else if (token.isRelation(JointFtrXml.R_LMD2))  node = d_tree.getLeftMostDependent  (node.id, 1);
      else if (token.isRelation(JointFtrXml.R_RMD2))  node = d_tree.getRightMostDependent (node.id, 1);
      else if (token.isRelation(JointFtrXml.R_LNS))  node = d_tree.getLeftNearestSibling (node.id);
View Full Code Here

    return false;
  }
 
  private int resetBeVerb(DEPState state)
  {
    DEPNode lambda = state.getLambda();
    DEPNode beta   = state.getBeta();
   
    if (isOutOfDomain(state, lambda, beta))
      return -1;
   
    DEPNode beVerb = lambda.getHead();
    String  subj   = lambda.getLabel();
    int     vType  = 0;
   
    if (beta.isPos(CTLibEn.POS_VBN))
      vType = 1;
    else if (beta.isPos(CTLibEn.POS_VBG))
      vType = 2;
    else if (beta.isPos(CTLibEn.POS_VBD))
    {
      String p2 = beta.getFeat(DEPLib.FEAT_POS2);
      if (p2 != null && p2.equals(CTLibEn.POS_VBN))  vType = 1;
    }
   
    if (vType > 0 && subj != null && (DEPLibEn.isSubject(subj) || (subj.equals(DEPLibEn.DEP_ATTR) && hasNoDependent(beVerb, 1, beta.id, state))))
    {
      DEPNode gHead = beVerb.getHead();
     
      // be - subj(lambda) -  vb[ng](beta)
      if (beVerb.isLemma(ENAux.BE) && beVerb.id < lambda.id && (gHead == null || gHead.id < beVerb.id))
      {
        int i, size = beta.id;
        DEPNode node;
       
        for (i=beVerb.id+1; i<size; i++)
        {
          node = state.getNode(i);
         
          if (node.isDependentOf(beVerb))
            node.setHead(beta);
        }
       
        clearPreviousDependents(beVerb, state);
        beVerb.setHead(beta);
       
View Full Code Here

//  ====================================== POS TAGS ======================================
 
  public boolean resetPOSTags()
  {
    boolean reset = false;
    DEPNode node;
    int i;
   
    for (i=1; i<t_size; i++)
    {
      if (n_2ndPos[i] > 0)
      {
        reset = true;
        node = d_tree.get(i);
        node.pos = node.removeFeat(DEPLib.FEAT_POS2);
      }
    }
   
    return reset;
  }
View Full Code Here

    return -1;
  }
 
  private boolean isOutOfDomain(DEPState state, DEPNode lambda, DEPNode beta)
  {
    DEPNode node;
    int i;
   
    for (i=beta.id-1; i>lambda.id; i--)
    {
      node = state.getNode(i);
     
      if (node.isDependentOf(beta) && (DEPLibEn.isSubject(node.getLabel()) || DEPLibEn.isAuxiliary(node.getLabel())))
        return true;
    }
   
    return false;
  }
View Full Code Here

    return false;
  }
 
  private boolean hasNoDependent(DEPNode head, int bIdx, int eIdx, DEPState state)
  {
    DEPNode node;
    int i;
   
    for (i=bIdx; i<eIdx; i++)
    {
      node = state.getNode(i);
     
      if (node.isDependentOf(head))
        return false;
    }
   
    return true;
  }
View Full Code Here

  }
 
  private boolean clearPreviousDependents(DEPNode head, DEPState state)
  {
    boolean found = false;
    DEPNode node;
    int i;
   
    for (i=head.id-1; i>0; i--)
    {
      node = state.getNode(i);
     
      if (node.isDependentOf(head))
      {
        node.clearHead();
        state.pushBack(node.id);
        found = true;
      }
    }
   
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.