Package com.clearnlp.dependency

Examples of com.clearnlp.dependency.DEPNode


  }
 
  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


  protected void postProcess(DEPState state)
  {
    if (!isDecode()) return;
   
    int i, size = state.getTreeSize(), vCount = 0;
    DEPNode node;
   
    for (i=1; i<size; i++)
    {
      node = state.getNode(i);
     
View Full Code Here

    }
  }
 
  private boolean postProcessPP(DEPNode node)
  {
    DEPNode head = node.getHead();
    if (head == nullreturn false;
   
    DEPNode gHead = head.getHead();
    if (gHead == nullreturn false;
   
    DEPNode ggHead = gHead.getHead();
    if (ggHead == nullreturn false;
   
    // node ggHead:VB gHead:NN head:IN
    if (node.id < ggHead.id && ggHead.id < gHead.id && gHead.id < head.id && head.isPos(CTLibEn.POS_IN) && MPLibEn.isNoun(gHead.pos) && MPLibEn.isVerb(ggHead.pos))
    {
View Full Code Here

 
  private boolean postProcessBeProperNounAdjective(DEPNode be, DEPState state)
  {
    if (be.isLemma(ENAux.BE) && MPLibEn.isVerb(be.pos) && be.id+2 < state.getTreeSize())
    {
      DEPNode jj = state.getNode(be.id+2);
     
      if (MPLibEn.isAdjective(jj.pos) && jj.isDependentOf(be) && jj.isLabel(DEPLibEn.DEP_NSUBJ))
      {
        DEPNode nnp = state.getNode(be.id+1);
       
        if (nnp.isPos(CTLibEn.POS_NNP) && nnp.isDependentOf(jj) && nnp.isLabel(DEPLibEn.DEP_NPADVMOD) && !containsDependent(state, be, DEPLibEn.DEP_ATTR, jj.id))
        {
          nnp.setHead(be, DEPLibEn.DEP_NSUBJ);
          jj.setLabel(DEPLibEn.DEP_ATTR);
          return true;
        }
      }
    }
View Full Code Here

  private boolean postProcessAttributeInQuestion(DEPNode appos, DEPState state)
  {
    if (!appos.isLabel(DEPLibEn.DEP_APPOS))
      return false;
   
    DEPNode nsubj = appos.getHead();
    if (nsubj == null || !nsubj.isLabel(DEPLibEn.DEP_NSUBJ) || nsubj.id > appos.id)
      return false;
   
    DEPNode be = nsubj.getHead();
    if (be == null || !be.isLemma(ENAux.BE) || be.id > appos.id)
      return false;
   
    int i, size = state.getTreeSize();
    DEPNode node;
   
    for (i=appos.id; i<size; i++)
    {
      node = state.getNode(i);
         
      if (node.isDependentOf(be, DEPLibEn.DEP_ATTR))
        return false;
    }
   
    appos.setHead(be, DEPLibEn.DEP_ATTR);
    return true;
View Full Code Here

    return true;
  }
 
  private boolean containsDependent(DEPState state, DEPNode head, String label, int bIdx)
  {
    DEPNode node;
    int i;
   
    for (i=state.getTreeSize()-1; i>bIdx; i--)
    {
      node = state.getNode(i);
     
      if (node.isDependentOf(head) && node.isLabel(label))
        return true;
    }
   
    return false;
  }
View Full Code Here

  }
 
  /** Called by {@link AbstractPOSTagger#processAux()}. */
  protected void addLexica(POSState state)
  {
    DEPNode node;

    while ((node = state.shift()) != null)
    {
      if (s_lsfs.contains(node.lowerSimplifiedForm))
        p_ambi.add(node.simplifiedForm, state.getGoldLabel());
View Full Code Here

 
  /** Called by {@link AbstractPOSTagger#processAux()}. */
  protected List<StringInstance> tag(POSState state)
  {
    List<StringInstance> insts = Lists.newArrayList();
    DEPNode node;
   
    while ((node = state.shift()) != null)
    {
      if (!applyRules(state))
        node.pos = getLabel(insts, state);
View Full Code Here

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

  @Override
  protected String getField(FtrToken token, POSState state)
  {
    DEPNode node = state.getNode(token);
    if (node == null) return null;
    Matcher m;
   
    if (token.isField(JointFtrXml.F_SIMPLIFIED_FORM))
    {
      return containsLowerSimplifiedForm(node) ? node.simplifiedForm : null;
    }
    else if (token.isField(JointFtrXml.F_LOWER_SIMPLIFIED_FORM))
    {
      return containsLowerSimplifiedForm(node) ? node.lowerSimplifiedForm : null;
    }
    else if (token.isField(JointFtrXml.F_LEMMA))
    {
      return containsLowerSimplifiedForm(node) ? node.lemma : null;
    }
    else if (token.isField(JointFtrXml.F_POS))
    {
      return node.pos;
    }
    else if (token.isField(JointFtrXml.F_AMBIGUITY_CLASS))
    {
      return m_ambi.get(node.simplifiedForm);
    }
    else if ((m = JointFtrXml.P_BOOLEAN.matcher(token.field)).find())
    {
      int field = Integer.parseInt(m.group(1));
     
      switch (field)
      {
      case  0: return UTString.isAllUpperCase(node.simplifiedForm) ? token.field : null;
      case  1: return UTString.isAllLowerCase(node.simplifiedForm) ? token.field : null;
      case  2: return UTString.beginsWithUpperCase(node.simplifiedForm) & !state.isInputFirstNode() ? token.field : null;
      case  3: return UTString.getNumOfCapitalsNotAtBeginning(node.simplifiedForm) == 1 ? token.field : null;
      case  4: return UTString.getNumOfCapitalsNotAtBeginning(node.simplifiedForm> 1 ? token.field : null;
      case  5: return node.simplifiedForm.contains(".") ? token.field : null;
      case  6: return UTString.containsDigit(node.simplifiedForm) ? token.field : null;
      case  7: return node.simplifiedForm.contains("-") ? token.field : null;
      case  8: return state.isInputLastNode() ? token.field : null;
      case  9: return state.isInputFirstNode() ? 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));
    }
    else if ((m = JointFtrXml.P_PREFIX.matcher(token.field)).find())
    {
      int n = Integer.parseInt(m.group(1)), len = node.lowerSimplifiedForm.length();
      return (n <= len) ? node.lowerSimplifiedForm.substring(0, n) : null;
View Full Code Here

  }
 
  @Override
  protected String[] getFields(FtrToken token, POSState state)
  {
    DEPNode node = state.getNode(token);
    if (node == null) return null;
    String[] fields = null;
    Matcher m;
   
    if ((m = JointFtrXml.P_PREFIX.matcher(token.field)).find())
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.