Examples of ConllDependencyNode


Examples of org.apache.ctakes.typesystem.type.syntax.ConllDependencyNode

    return nodes.length;
  }

  private static ConllDependencyNode getDepLCA(ConllDependencyNode c1, ConllDependencyNode c2) {
    HashSet<Annotation> ancestors = new HashSet<Annotation>();
    ConllDependencyNode temp = null;
    temp = c2.getHead();
    while(temp != null){
      ancestors.add(temp);
      temp = temp.getHead();
    }
    temp = c1.getHead();
    while(temp != null){
      if(ancestors.contains(temp)){
        break;
      }
      temp = temp.getHead();
    }
    return temp;
  }
View Full Code Here

Examples of org.apache.ctakes.typesystem.type.syntax.ConllDependencyNode

      }else{
        StringBuffer buf = new StringBuffer();

        // first go up from the anaphor to the Lowest common ancestor... (LCA)
        buf.append(c2.getDeprel());
        ConllDependencyNode cur = c2.getHead();
        while(cur != depLca && cur != null){
          String rel = cur.getDeprel();
          if(rel == null){
            cur = null;
            break;
          }
          buf.append("<");
          buf.append(cur.getDeprel());
          cur = cur.getHead();
        }

        // add a "discourse node" if the relation goes between sentences.
        if(cur == null) buf.append("<TOP");

        // now up from the antecedent to the LCA
        StringBuffer bwd = new StringBuffer();
        bwd.append(c1.getDeprel());
        bwd.insert(0, ">");
        cur = c1.getHead();
        while(cur != depLca && cur != null){
          String rel = cur.getDeprel();
          if(rel == null){
            cur = null;
            break;
          }
          bwd.insert(0,cur.getDeprel());
          bwd.insert(0,">");
          cur = cur.getHead();
        }

        buf.append(bwd);
        depPath = buf.toString();
        initNGrams(ngrams, depPath, 3);
View Full Code Here

Examples of org.apache.ctakes.typesystem.type.syntax.ConllDependencyNode

    }else{
      return feats;
    }
   
    List<ConllDependencyNode> nodes = DependencyUtility.getDependencyNodes(jcas, sent);
    ConllDependencyNode headNode = DependencyUtility.getNominalHeadNode(jcas, focusAnnotation);
    try {
      boolean[] regexFeats = conAnal.findNegationContext(nodes, headNode);
      for(int j = 0; j < regexFeats.length; j++){
        if(regexFeats[j]){
          feats.add(new Feature("DepPath_" + conAnal.getRegexName(j))); //"NEG_DEP_REGEX_"+j));
View Full Code Here

Examples of org.apache.ctakes.typesystem.type.syntax.ConllDependencyNode

      }
     
      // now look for dependency relations:
      List<ConllDependencyNode> coveredNodes = JCasUtil.selectCovered(jcas, ConllDependencyNode.class, lastWord);
      if(coveredNodes.size() > 0){
        ConllDependencyNode curNode = coveredNodes.get(0);
        ConllDependencyNode predNode = null;
        if(pred != null){
          List<ConllDependencyNode> predNodes = JCasUtil.selectCovered(jcas, ConllDependencyNode.class, pred);
          if(predNodes.size() > 0){
            predNode = predNodes.get(0);
          }
View Full Code Here

Examples of org.apache.ctakes.typesystem.type.syntax.ConllDependencyNode

  public List<Feature> extract(JCas jCas, Annotation arg) {
   
    List<Feature> features = new ArrayList<Feature>();
   
    // Pull in general dependency-based features -- externalize to another extractor?
      ConllDependencyNode node = DependencyUtility.getNominalHeadNode(jCas, arg);
      if (node!= null) {
//        features.add(new Feature("DEPENDENCY_HEAD", node));
        features.add(new Feature("DEPENDENCY_HEAD_word", node.getCoveredText()));
//        features.add(new Feature("DEPENDENCY_HEAD_pos", node.getPostag()));
        features.add(new Feature("DEPENDENCY_HEAD_deprel", node.getDeprel()));
//        features.add(new Feature("DEPENDENCY_HEAD_lemma", node.getLemma()));
    }
     
      HashMap<String, Boolean> featsMap = HistoryAttributeClassifier.extract(jCas, arg);
View Full Code Here

Examples of org.apache.ctakes.typesystem.type.syntax.ConllDependencyNode

    }
   
   
    List<ConllDependencyNode> depnodes = JCasUtil.selectCovered(jCas, ConllDependencyNode.class, arg);
    if (!depnodes.isEmpty()) {
      ConllDependencyNode depnode = DependencyUtility.getNominalHeadNode(depnodes);

      // 1) check if the head node of the entity mention is really just part of a larger noun phrase
      if (depnode.getDeprel().matches("(NMOD|amod|nmod|det|predet|nn|poss|possessive|infmod|partmod|rcmod)")) {
        vfeat.put(POSTCOORD_NMOD, true);
      }

      // 4) search dependency paths for discussion context
      for (ConllDependencyNode dn : DependencyUtility.getPathToTop(jCas, depnode)) {
View Full Code Here

Examples of org.apache.ctakes.typesystem.type.syntax.ConllDependencyNode

   
    // search dependency paths for stuff
    List<ConllDependencyNode> depnodes = JCasUtil.selectCovered(jCas, ConllDependencyNode.class, mention);
    if (!depnodes.isEmpty()) {
      ConllDependencyNode depnode = DependencyUtility.getNominalHeadNode(depnodes);
      for (ConllDependencyNode dn : DependencyUtility.getPathToTop(jCas, depnode)) {
        if ( isDonorTerm(dn) ) {
          vfeat.put(DONOR_DEPPATH, true);
        }
        if ( isFamilyTerm(dn) ) {
View Full Code Here

Examples of org.apache.ctakes.typesystem.type.syntax.ConllDependencyNode

  public List<Feature> extract(JCas jCas, IdentifiedAnnotation arg1,
      IdentifiedAnnotation arg2) throws AnalysisEngineProcessException {
   
    List<Feature> features = new ArrayList<Feature>();
   
      ConllDependencyNode node1 = DependencyParseUtils.findAnnotationHead(jCas, arg1);
      ConllDependencyNode node2 = DependencyParseUtils.findAnnotationHead(jCas, arg2);
      if (node1 == null || node2 == null) { return features; }
     
      List<LinkedList<ConllDependencyNode>> paths = DependencyParseUtils.getPathsToCommonAncestor(node1, node2);
      LinkedList<ConllDependencyNode> path1 = paths.get(0);
      LinkedList<ConllDependencyNode> path2 = paths.get(1);
View Full Code Here

Examples of org.apache.ctakes.typesystem.type.syntax.ConllDependencyNode

      return features;
  }
 
  public List<Feature> extractForNode(JCas jCas, IdentifiedAnnotation mention, String ftrPrefix) {
      List<Feature> features = new ArrayList<Feature>();
      ConllDependencyNode mentionHeadNode = DependencyParseUtils.findAnnotationHead(jCas, mention);
   
      if (mentionHeadNode != null) {
        ConllDependencyNode dependsOn = mentionHeadNode.getHead();
        if (dependsOn != null) {
          features.add(new Feature(ftrPrefix + "_DEPENDS_ON_WORD", dependsOn.getCoveredText()));
          features.add(new Feature(ftrPrefix + "_DEPENDS_ON_POS", dependsOn.getPostag()));
          // Following features come from Zhou et al. 2005
          // ET1DW1: combination of the entity type and the dependent word for M1
          features.add(new Feature(ftrPrefix + "_TYPE-GOVERNING_WORD", String.format("%d-%s", mention.getTypeID(), dependsOn.getCoveredText())));
          // H1DW1: combination of the head word and the dependent word for M1
          features.add(new Feature(ftrPrefix + "_HEAD_WORD-GOVERNING_WORD", String.format("%s-%s", mentionHeadNode.getCoveredText(), dependsOn.getCoveredText())));
          features.add(new Feature(ftrPrefix + "_TYPE-GOVERNING_POS", String.format("%d-%s", mention.getTypeID(), dependsOn.getPostag())));
          features.add(new Feature(ftrPrefix + "_HEAD_POS-GOVERNING_POS", String.format("%s-%s", mentionHeadNode.getPostag(), dependsOn.getPostag())));
        }
      }
      return features;
  }
View Full Code Here

Examples of org.apache.ctakes.typesystem.type.syntax.ConllDependencyNode

  public static ConllDependencyNode markableNode(JCas jcas, int begin, int end, TreebankNode n) {
    // Find head of markable using treebanknode
    TerminalTreebankNode term = MarkableTreeUtils.getHead(n);
    FSIterator<Annotation> iter = jcas.getAnnotationIndex(ConllDependencyNode.type).iterator();
    ConllDependencyNode best = null;
   
    while(iter.hasNext()){
      Annotation a = iter.next();
      if(a.getBegin() == term.getBegin() && a.getEnd() == term.getEnd()){
        best = (ConllDependencyNode) a;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.