Examples of TreebankNode


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

    else return new MarkableProb(null,0.0);
  }
 
  private MarkableProb processDem(Markable anaphor, List<Markable> anteList, JCas jcas){
    double bestProb = 0.0;
    TreebankNode n = MarkableTreeUtils.markableNode(jcas, anaphor.getBegin(), anaphor.getEnd());
    TreebankNode parent = (n != null ? n.getParent() : null);
    TreebankNode gparent = (parent != null ? parent.getParent() : null);
    Markable ante = null;
    for(Markable antecedent: anteList){
      if(n!=null && parent != null && gparent != null && n.getNodeType().equals("WHNP") && parent.getNodeType().equals("SBAR")
          && gparent.getNodeType().equals("NP") && gparent.getChildren(1) == parent && gparent.getChildren(0).getNodeType().equals("NP")){
        TreebankNode anteNode = gparent.getChildren(0);
        Markable trueAnte = MarkableTreeUtils.nodeMarkable(jcas, anteNode.getBegin(), anteNode.getEnd());
        if(trueAnte == antecedent){
          bestProb = 1.0;
          ante = antecedent;
          break;
        }
View Full Code Here

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

  public List<Feature> extract(JCas jcas, int begin, int end)
      {
    List<Feature> feats = new ArrayList<Feature>();
   
    TreebankNode domNode = AnnotationTreeUtils.annotationNode(jcas, begin, end);
    if(domNode != null){
      feats.add(new Feature("DominatingTreeCat", domNode.getNodeType()));
      if(domNode.getNodeTags() != null){
        for(int ind = 0; ind < domNode.getNodeTags().size(); ind++){
          String tag = domNode.getNodeTags(ind);
          if(tag.equals("TMP")){
            feats.add(new Feature("DominatingTmpTag", tag));
          }
        }
      }
      TreebankNode parent = domNode.getParent();
      if(parent != null){
        feats.add(new Feature("DominatingTreeParent", parent.getNodeType()));
        do{
          if(parent.getNodeTags() != null){
            for(int ind = 0; ind < parent.getNodeTags().size(); ind++){
              String tag = parent.getNodeTags(ind);
//              if(tag.equals("TMP")){
                feats.add(new Feature("DominatingAncestorTmpTag", tag));
//              }
            }
          }
          parent = parent.getParent();
        }while(parent != null);
      }
     
      if(domNode.getLeaf()){
        feats.add(new Feature("DominatingIsLeaf"));
View Full Code Here

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

  @Override
  public List<Feature> extract(JCas jCas, IdentifiedAnnotation arg1,
      IdentifiedAnnotation arg2) throws AnalysisEngineProcessException {
    List<Feature> features = new ArrayList<Feature>();
   
    TreebankNode tree1 = AnnotationTreeUtils.annotationNode(jCas, arg1);
    TreebankNode tree2 = AnnotationTreeUtils.annotationNode(jCas, arg2);
    TreebankNode phrase1 = tree1;
    TreebankNode phrase2 = tree2;
   
    while(phrase1.getParent() != null){
      phrase1 = phrase1.getParent();
      if(phrase1.getNodeType().endsWith("P")) break;
    }
    while(phrase2.getParent() != null){
      phrase2 = phrase2.getParent();
      if(phrase2.getNodeType().endsWith("P")) break;
    }
   
   
    if(phrase1.getBegin() <= phrase2.getBegin() && phrase1.getEnd() >= phrase2.getEnd()){
      features.add(new Feature("Arg1DominatesArg2"));
    }else if(phrase2.getBegin() <= phrase1.getBegin() && phrase2.getEnd() >= phrase1.getEnd()){
      features.add(new Feature("Arg2DominatesArg1"));
    }
   
//    TreebankNode lca = AnnotationTreeUtils.getCommonAncestor(tree1, tree2);
//    features.add(new Feature("LCA", lca));
View Full Code Here

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

      IdentifiedAnnotation secondArg, String prefix) {
    List<Feature> feats = Lists.newArrayList();
   
    List<TreebankNode> nodes = JCasUtil.selectCovered(TreebankNode.class, primeArg);
    if(nodes.size() > 0){
      TreebankNode node = nodes.get(0);
      if(node.getBegin() == primeArg.getBegin() && node.getEnd() == primeArg.getEnd()){
        HashSet<String> priorNPs = new HashSet<String>();
        // we have a node with the exact span as the argument
        // now check if it is an element of a list
        // first move NNs up to their constituent
        if(node.getNodeType().startsWith("NN")){
          node = node.getParent();
        }
        TreebankNode parent = node.getParent();
        if(parent == null) return feats;
        int childIndex = -1;
        for(int i = 0; i < parent.getChildren().size(); i++){
          if(parent.getChildren(i) == node){
            childIndex = i;
            break;
          }
          priorNPs.add(getKey(parent.getChildren(i)));
        }
          
        // cnoditions for this arg being an element of a list:
        // 1) is NP
        // 2) Parent is NP
        // 3) left neighbor is , or right neighbor is , or both neigbors are ,
        boolean lcComma=false, rcComma=false, lcAnd=false;
        if(node.getNodeType().equals("NP") && parent.getNodeType().equals("NP")){
          if(childIndex > 0 && parent.getChildren(childIndex-1).getNodeType().equals(",")){
            // left child is ","
            lcComma = true;
          }
          if(childIndex+1 < parent.getChildren().size() && parent.getChildren(childIndex+1).getNodeType().equals(",")){
            rcComma = true;
          }
          if(childIndex+1 == parent.getChildren().size() && childIndex > 0 && parent.getChildren(childIndex-1).getNodeType().equals("CC")){
            lcAnd = true;
          }
        }
        if(lcComma && rcComma){
          feats.add(new Feature(prefix + "_midlist", true));
View Full Code Here

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

  public List<Feature> extract(JCas jcas, IdentifiedAnnotation arg1,
      IdentifiedAnnotation arg2) throws AnalysisEngineProcessException {
    List<Feature> feats = Lists.newArrayList();
   
   
    TreebankNode arg1node = AnnotationTreeUtils.annotationNode(jcas, arg1);
    feats.add(new Feature("Arg1Parent", arg1node.getNodeType()));
    TreebankNode arg2node = AnnotationTreeUtils.annotationNode(jcas, arg2);
    feats.add(new Feature("Arg2Parent", arg2node.getNodeType()));
       
    return feats;
  }
View Full Code Here

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

    }else if(arg2 instanceof TimeMention){
      timeClass = ((TimeMention)arg2).getTimeClass();
      a2type = "TIMEX-"+timeClass;     
    }
   
    TreebankNode t1 = AnnotationTreeUtils.insertAnnotationNode(jcas, root, arg1, "ARG1-"+a1type);
    TreebankNode t2 = AnnotationTreeUtils.insertAnnotationNode(jcas, root, arg2, "ARG2-"+a2type);

    SimpleTree tree = null;
    tree = TreeExtractor.extractPathTree(t1, t2);
    TemporalPETExtractor.simplifyGCG(tree);
    features.add(new TreeFeature("TK_PATH", tree.toString()));
View Full Code Here

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

    }else if(arg2 instanceof TimeMention){
      timeClass = ((TimeMention)arg2).getTimeClass();
      a2type = "TIMEX-"+timeClass;     
    }
   
    TreebankNode t1 = AnnotationTreeUtils.insertAnnotationNode(jcas, root, arg1, "ARG1-"+a1type);
    TreebankNode t2 = AnnotationTreeUtils.insertAnnotationNode(jcas, root, arg2, "ARG2-"+a2type);

//    addOtherTimes(jcas,root, arg1, arg2);
       
    SimpleTree tree = null;
    if(t1.getBegin() <= t2.getBegin() && t1.getEnd() >= t2.getEnd()){
      // t1 encloses t2
      tree = TreeExtractor.getSimpleClone(t1);
    }else if(t2.getBegin() <= t1.getBegin() && t2.getEnd() >= t1.getEnd()){
      // t2 encloses t1
      tree = TreeExtractor.getSimpleClone(t2);
    }else{
//      tree = TreeExtractor.extractPathEnclosedTree(t1, t2, jcas);
      tree = TreeExtractor.getSimpleClone(root);
View Full Code Here

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

    }else if(arg2 instanceof TimeMention){
      timeClass = ((TimeMention)arg2).getTimeClass();
      a2type = "TIMEX-"+timeClass;     
    }
   
    TreebankNode t1 = AnnotationTreeUtils.insertAnnotationNode(jcas, root, arg1, "ARG1-"+a1type);
    TreebankNode t2 = AnnotationTreeUtils.insertAnnotationNode(jcas, root, arg2, "ARG2-"+a2type);

//    addOtherTimes(jcas,root, arg1, arg2);
       
    SimpleTree tree = null;
    if(t1.getBegin() <= t2.getBegin() && t1.getEnd() >= t2.getEnd()){
      // t1 encloses t2
      tree = TreeExtractor.getSimpleClone(t1);
    }else if(t2.getBegin() <= t1.getBegin() && t2.getEnd() >= t1.getEnd()){
      // t2 encloses t1
      tree = TreeExtractor.getSimpleClone(t2);
    }else{
      tree = TreeExtractor.extractPathEnclosedTree(t1, t2, jcas);
    }
View Full Code Here

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

        throw new AnalysisEngineProcessException();
      }
      for(TimeMention mention : JCasUtil.select(goldView, TimeMention.class)){
        // for each time expression, get the treebank node with the same span.
        List<TreebankNode> nodes = JCasUtil.selectCovered(systemView, TreebankNode.class, mention);
        TreebankNode sameSpanNode = null;
        for(TreebankNode node : nodes){
          if(node.getBegin() == mention.getBegin() && node.getEnd() == mention.getEnd()){
            sameSpanNode = node;
            break;
          }
        }
        if(sameSpanNode != null){
          // look at node at the position of the timex3.
          if(sameSpanNode.getNodeType().equals("PP")){
            // if it is a PP it should be moved down to the NP
            int numChildren = sameSpanNode.getChildren().size();
            if(numChildren == 2 && sameSpanNode.getChildren(0).getNodeType().equals("IN") && sameSpanNode.getChildren(1).getNodeType().equals("NP")){
              // move the time span to this node:
              TreebankNode mentionNode = sameSpanNode.getChildren(numChildren-1);
              mention.setBegin(mentionNode.getBegin());
              mention.setEnd(mentionNode.getEnd());
            }
          }
        }else{
          // if there is no matching tree span, see if the DT to the left would help.
          // now adjust for missing DT to the left
View Full Code Here

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

     
      // for each event, cmopute the tree distance to the root, and call the closest to the root the anchor.
      int minDepth = Integer.MAX_VALUE;
      EventMention anchorMention = null;
      for(EventMention event : events){
        TreebankNode node = AnnotationTreeUtils.annotationNode(jCas, event);
        int depth = 0;
        while(node.getParent() != null){
          depth++;
          node = node.getParent();
        }
        if(depth < minDepth){
          minDepth = depth;
          anchorMention = event;
        }
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.