Package org.apache.ctakes.utils.tree

Examples of org.apache.ctakes.utils.tree.SimpleTree


    tree = extractAboveLeftConceptTree(jcas, mention, sems);   
    return tree;
  }

  private static SimpleTree getNegationTree(JCas jcas, IdentifiedAnnotation mention) {
    SimpleTree tree = null;
    tree = extractAboveLeftConceptTree(jcas, mention, sems);
    return tree;
  }
View Full Code Here


      for(IdentifiedAnnotation mention : mentions){

        if(lastSent != null && lastSent.getCoveredText().startsWith("Indications")){
          continue;
        }
        SimpleTree tree = AssertionDepUtils.getTokenTreeString(jcas, nodes, mention, UP_NODES);
       
//        String treeStr = AnnotationDepUtils.getTokenRelTreeString(jcas, nodes, new Annotation[]{mention}, new String[]{"CONCEPT"}, true);
       
        if(tree == null) continue;
        AssertionTreeUtils.replaceDependencyWordsWithSemanticClasses(tree, sems);
        String label = "-1";
       
       
        if(options.attributeType == ATTRIBUTE.NEG && mention.getPolarity() == CONST.NE_POLARITY_NEGATION_PRESENT ||
           options.attributeType == ATTRIBUTE.UNC && mention.getUncertainty() == CONST.NE_UNCERTAINTY_PRESENT){
          label = "+1";
        }
       
        out.print(label);
        out.print(" |BT| ");
        out.print(tree.toString()); //tree.toString());
        out.println(" |ET|");
        out.flush();
//        // restore cat name:
//        node2tree.get(headNode).cat = realCat;
View Full Code Here

import org.apache.uima.jcas.tcas.Annotation;

public class AssertionTreeUtils {

  public static SimpleTree extractAboveLeftConceptTree(JCas jcas, Annotation mention, SemanticClasses sems){
    SimpleTree tree = null;
    TopTreebankNode annotationTree = AnnotationTreeUtils.getAnnotationTree(jcas, mention);
    if(annotationTree != null){
      TopTreebankNode root = AnnotationTreeUtils.getTreeCopy(jcas, annotationTree);
      TreebankNode conceptNode = AnnotationTreeUtils.insertAnnotationNode(jcas, root, mention, "CONCEPT");
      // navigate up the tree to retrieve the first "S" above this node.
View Full Code Here

      }
    }
  }

  public static SimpleTree extractAboveRightConceptTree(JCas jcas, Annotation mention, SemanticClasses sems){
    SimpleTree tree = null;
    TopTreebankNode annotationTree = AnnotationTreeUtils.getAnnotationTree(jcas, mention);
    if(annotationTree != null){
      TopTreebankNode root = AnnotationTreeUtils.getTreeCopy(jcas, annotationTree);
      TreebankNode conceptNode = AnnotationTreeUtils.insertAnnotationNode(jcas, root, mention, "CONCEPT");
      //            SimpleTree tree = null;
View Full Code Here

import org.apache.uima.jcas.tcas.Annotation;

public class AssertionTreeUtils {

  public static SimpleTree extractAboveLeftConceptTree(JCas jcas, Annotation mention, SemanticClasses sems){
    SimpleTree tree = null;
    TopTreebankNode annotationTree = AnnotationTreeUtils.getAnnotationTree(jcas, mention);
    if(annotationTree != null){
      TopTreebankNode root = AnnotationTreeUtils.getTreeCopy(jcas, annotationTree);
      TreebankNode conceptNode = AnnotationTreeUtils.insertAnnotationNode(jcas, root, mention, "CONCEPT");
      // navigate up the tree to retrieve the first "S" above this node.
View Full Code Here

    }
    return tree;
  }
 
  public static SimpleTree extractAboveRightConceptTree(JCas jcas, Annotation mention, SemanticClasses sems){
    SimpleTree tree = null;
    TopTreebankNode annotationTree = AnnotationTreeUtils.getAnnotationTree(jcas, mention);
    if(annotationTree != null){
      TopTreebankNode root = AnnotationTreeUtils.getTreeCopy(jcas, annotationTree);
      TreebankNode conceptNode = AnnotationTreeUtils.insertAnnotationNode(jcas, root, mention, "CONCEPT");
      //            SimpleTree tree = null;
View Full Code Here

      TopTreebankNode orig = AnnotationTreeUtils.getAnnotationTree(jcas, mention);
      if(orig == null){
        log.warn("Tree for entity mention: " + mention.getCoveredText() + " (" + mention.getBegin() + "-" + mention.getEnd() + ") is null.");
        continue;
      }
      SimpleTree tree = extractAboveLeftConceptTree(jcas, mention, sems);
//      if(mention.getPolarity() == CONST.NE_POLARITY_NEGATION_PRESENT){
      if(mention.getUncertainty() == CONST.NE_UNCERTAINTY_PRESENT){
        out.print("+1 ");
      }else{
        out.print("-1 ");
      }
     
      out.print("|BT| ");
      out.print(tree.toString());
      out.println(" |ET|");
      out.flush();
    }
  }
View Full Code Here

    // 2) overlapping trees
    if(t1 == t2 || (t1.getBegin() >= t2.getBegin() && t1.getEnd() <= t2.getEnd()) || (t2.getBegin() >= t1.getBegin() && t2.getEnd() <= t1.getEnd())){
      return sameTree(t1, t2);
    }
   
    SimpleTree node = null;
    TreebankNode lca = getLCA(t1, t2);
    if(lca == null) node = new SimpleTree("TOP");
    else node = new SimpleTree(lca.getNodeType());
   
    ArrayList<TreebankNode> antePath = getUpwardPath(lca, t1);
    SimpleTree parent = node;
    for(TreebankNode child : antePath){
      SimpleTree newChild = new SimpleTree(child.getNodeType());
      parent.addChild(newChild);
      parent = newChild;   
    }
    parent.addChild(new SimpleTree("arg1"));
   
    ArrayList<TreebankNode> anaPath = getUpwardPath(lca, t2);
    parent = node;
    for(TreebankNode child : anaPath){
      SimpleTree newChild = new SimpleTree(child.getNodeType());
      parent.addChild(newChild);
      parent = newChild;
    }
    parent.addChild(new SimpleTree("arg2"));
   
    return node;
  }
View Full Code Here

   
    return node;
  }

  public static SimpleTree extractPathEnclosedTree(TreebankNode t1, TreebankNode t2, JCas jcas){
    SimpleTree node = null;
    // swap them if wrong order:
    if(t1.getBegin() > t2.getBegin()){
      TreebankNode temp = t1;
      t1 = t2;
      t2 = temp;
View Full Code Here

    }
    return node;
  }

  private static SimpleTree buildSimpleClonePET(TreebankNode lca, TreebankNode t1, TreebankNode t2){
    SimpleTree t = new SimpleTree(lca.getNodeType());
    if(lca instanceof TerminalTreebankNode){
      t.addChild(new SimpleTree(lca.getNodeValue()));
    }else{
      for(int i = 0; i < lca.getChildren().size(); i++){
        TreebankNode tn = lca.getChildren(i);
        if(tn.getEnd() > t1.getBegin() && tn.getBegin() < t2.getEnd()){
          t.addChild(buildSimpleClonePET(lca.getChildren(i), t1, t2));
        }
      }
    }
    return t;
  }
View Full Code Here

TOP

Related Classes of org.apache.ctakes.utils.tree.SimpleTree

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.