Package com.clearnlp.constituent

Examples of com.clearnlp.constituent.CTNode


   */
  private boolean findHeadsCoordination(HeadRule rule, CTNode curr)
  {
    // skip pre-conjunctions and punctuation
    int i, sId, size = curr.getChildrenSize();
    CTNode node;
   
    for (sId=0; sId<size; sId++)
    {
      node = curr.getChild(sId);
     
      if (!CTLibEn.isPunctuation(node) && !CTLibEn.isConjunction(node))
        break;
    }
   
    if (!CTLibEn.containsCoordination(curr, curr.getChildren(sId)))
      return false;
   
    // find conjuncts
    Pattern rTags = getConjunctPattern(curr, sId, size);
    CTNode prevHead = null, mainHead = null;
    boolean isFound = false;
    int bId = 0, eId = sId;
   
    for (; eId<size; eId++)
    {
View Full Code Here


  }
 
  /** Called by {@link EnglishC2DConverter#findHeadsCoordination(HeadRule, CTNode)}. */
  private CTNode findHeadsCoordinationAux(HeadRule rule, CTNode curr, int bId, int eId, CTNode lastHead)
  {
    CTNode currHead = (eId - bId == 1) ? curr.getChild(bId) : getHead(rule, curr.getChildren(bId, eId), SIZE_HEAD_FLAGS);
   
    if (lastHead != null)
    {
      String label = DEPLibEn.DEP_CONJ;
     
View Full Code Here

  }
 
  private boolean findHyphens(CTNode node)
  {
    int i, size = node.getChildrenSize();
    CTNode prev, hyph, next;
    boolean isFound = false;
    boolean isVP = node.isPTag(CTLibEn.PTAG_VP);
   
    for (i=0; i<size-2; i++)
    {
View Full Code Here

  private boolean findHeadsApposition(CTNode curr)
  {
    if (!curr.isPTagAny(CTLibEn.PTAG_NP, CTLibEn.PTAG_NML) || curr.containsTags("+NN.*"))
      return false;
   
    CTNode fst = curr.getFirstChild("+NP|NML"), snd;
    while (fst != null && fst.containsTags(CTLibEn.POS_POS))
      fst = fst.getNextSibling("+NP|NML");
   
    if (fst == null || fst.c2d.hasHead())  return false;
   
    int i, size = curr.getChildrenSize();
    boolean hasAppo = false;
   
    for (i=fst.getSiblingId()+1; i<size; i++)
    {
      snd = curr.getChild(i);
      if (snd.c2d.hasHead())  continue;
     
      if ((snd.isPTagAny(CTLibEn.PTAG_NP, CTLibEn.PTAG_NML) && !hasAdverbialTag(snd)) ||
View Full Code Here

    return hasAppo;
  }

  private boolean findHeadsSmallClause(CTNode node)
  {
    CTNode parent = node.getParent();
   
    if (node.isPTag(CTLibEn.PTAG_S) && !node.containsTags(CTLibEn.PTAG_VP))
    {
      CTNode sbj = node.getFirstChild("-"+CTLibEn.FTAG_SBJ);
      CTNode prd = node.getFirstChild("-"+CTLibEn.FTAG_PRD);
     
      if (sbj != null && prd != null)
      {
        if (parent.isPTag(CTLibEn.PTAG_SQ))
        {
          CTNode vb = parent.getFirstChild("+VB.*");
         
          if (vb != null)
          {
            sbj.c2d.setHead(vb, getDEPLabel(sbj, parent, vb));
            node.pTag = prd.pTag;
View Full Code Here

  // ============================= Get Stanford labels =============================
 
  @Override
  protected String getDEPLabel(CTNode C, CTNode P, CTNode p)
  {
    CTNode c = C.c2d.getPhraseHead();
    CTNode d = C.c2d.getDependencyHead();
    String label;
   
    // function tags
    if (hasAdverbialTag(C))
    {
      if (C.isPTagAny(CTLibEn.PTAG_S, CTLibEn.PTAG_SBAR, CTLibEn.PTAG_SINV))
        return DEPLibEn.DEP_ADVCL;
     
      if (C.isPTagAny(CTLibEn.PTAG_NML, CTLibEn.PTAG_NP, CTLibEn.PTAG_QP))
        return DEPLibEn.DEP_NPADVMOD;
    }
   
    if ((label = getSubjectLabel(C, d)) != null)
      return label;
   
    // coordination
    if (C.isPTag(CTLibEn.PTAG_UCP))
    {
      c.addFTags(C.getFTags());
      return getDEPLabel(c, P, p);
    }
   
    // complements
    if (P.isPTagAny(CTLibEn.PTAG_VP, CTLibEn.PTAG_SINV, CTLibEn.PTAG_SQ))
    {
      if (isAcomp(C))  return DEPLibEn.DEP_ACOMP;
      if ((label = getObjectLabel(C)) != nullreturn label;
      if (isOprd(C))  return DEPLibEn.DEP_OPRD;
      if (isXcomp(C))  return DEPLibEn.DEP_XCOMP;
      if (isCcomp(C))  return DEPLibEn.DEP_CCOMP;
      if ((label = getAuxLabel(C)) != null)    return label;
    }
   
    if (P.isPTagAny(CTLibEn.PTAG_ADJP, CTLibEn.PTAG_ADVP))
    {
      if (isXcomp(C))  return DEPLibEn.DEP_XCOMP;
      if (isCcomp(C))  return DEPLibEn.DEP_CCOMP;
    }
   
    if (P.isPTagAny(CTLibEn.PTAG_NML, CTLibEn.PTAG_NP, CTLibEn.PTAG_WHNP))
    {
      if (isNfmod(C))  return isInfMod(C) ? DEPLibEn.DEP_INFMOD : DEPLibEn.DEP_PARTMOD;
      if (isRcmod(C))  return DEPLibEn.DEP_RCMOD;
      if (isCcomp(C))  return DEPLibEn.DEP_CCOMP;
    }
   
    if (isPoss(C, P))
      return DEPLibEn.DEP_POSS;
   
    // simple labels
    if ((label = getSimpleLabel(C)) != null)
      return label;
     
    // default
    if (P.isPTagAny(CTLibEn.PTAG_PP, CTLibEn.PTAG_WHPP))
    {
      if (p.getParent() == C.getParent())  // p and C are siblings
      {
        if (p.getSiblingId() < C.getSiblingId())
          return getPmodLabel(C, d);
      }
      else                // UCP
      {
        if (p.getFirstTerminal().getTerminalId() < C.getFirstTerminal().getTerminalId())
          return getPmodLabel(C, d);
      }
    }
   
    if (C.isPTag(CTLibEn.PTAG_SBAR) || isXcomp(C) || (P.isPTag(CTLibEn.PTAG_PP) && CTLibEn.isClause(C)))
      return DEPLibEn.DEP_ADVCL;
   
    if (C.isPTagAny(CTLibEn.PTAG_S, CTLibEn.PTAG_SINV, CTLibEn.PTAG_SQ, CTLibEn.PTAG_SBARQ))
      return DEPLibEn.DEP_CCOMP;
   
    if (P.isPTag(CTLibEn.PTAG_QP))
    {
      if (C.isPTagAny(CTLibEn.POS_CD))
        return DEPLibEn.DEP_NUMBER;
      else
        return DEPLibEn.DEP_QUANTMOD;
    }
   
    if (P.isPTagAny(CTLibEn.PTAG_NML, CTLibEn.PTAG_NP, CTLibEn.PTAG_NX, CTLibEn.PTAG_WHNP) || CTLibEn.isNoun(p))
      return getNmodLabel(C);
   
    if (c != null)
    {
      if ((label = getSimpleLabel(c)) != null)
        return label;
     
      if (d.isPTag(CTLibEn.POS_IN))
        return DEPLibEn.DEP_PREP;
     
      if (CTLibEn.isAdverb(d))
        return DEPLibEn.DEP_ADVMOD;
    }
View Full Code Here

    return null;
  }
 
  private String getSpecialLabel(CTNode C)
  {
    CTNode d = C.c2d.getDependencyHead();
   
    if (CTLibEn.isPunctuation(C) || CTLibEn.isPunctuation(d))
      return DEPLibEn.DEP_PUNCT;
   
    if (isIntj(C) || isIntj(d))
View Full Code Here

  private String getAuxLabel(CTNode node)
  {
    if (node.isPTagAny(CTLibEn.POS_MD, CTLibEn.POS_TO))
      return DEPLibEn.DEP_AUX;

    CTNode vp;
   
    if (CTLibEn.isVerb(node) && (vp = node.getNextSibling(CTLibEn.PTAG_VP)) != null)
    {
      if ((MPLibEn.isBe(node.form) || MPLibEn.isBecome(node.form) || MPLibEn.isGet(node.form)))
      {
        if (vp.containsTags("+VBN|VBD"))
          return DEPLibEn.DEP_AUXPASS;
       
        if (!vp.containsTags("+VB.*") && (vp = vp.getFirstChild(CTLibEn.PTAG_VP)) != null && vp.containsTags("+VBN|VBD"))
          return DEPLibEn.DEP_AUXPASS;
      }
     
      return DEPLibEn.DEP_AUX;
    }
View Full Code Here

 
  private boolean isAdv(CTNode C)
  {
    if (C.isPTag(CTLibEn.PTAG_ADVP) || CTLibEn.isAdverb(C))
    {
      CTNode P = C.getParent();
      int id = C.getSiblingId();
     
      if (P.isPTagAny(CTLibEn.PTAG_PP, CTLibEn.PTAG_WHPP) && id+1 == P.getChildrenSize() && P.getChild(id-1).isPTagAny(CTLibEn.POS_IN, CTLibEn.POS_TO))
        return false;

      return true;
    }
   
View Full Code Here

    if (curr.hasFTag(DEPLibEn.DEP_OPRD))
      return true;
   
    if (curr.isPTag(CTLibEn.PTAG_S) && !curr.containsTags(CTLibEn.PTAG_VP) && curr.containsTags("-"+CTLibEn.FTAG_PRD))
    {
      CTNode sbj = curr.getFirstChild("-"+CTLibEn.FTAG_SBJ);
      return sbj != null && sbj.isEmptyCategoryRec();
    }
   
    return false;
  }
View Full Code Here

TOP

Related Classes of com.clearnlp.constituent.CTNode

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.