Examples of TreebankNode


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

      if(conceptIndex == 0 && tree.getChildren().size() > 1 && tree.getChildren(1).getNodeType().matches("CC|,")
          || conceptIndex == tree.getChildren().size()-1 && tree.getChildren().size() > 1 && tree.getChildren(conceptIndex-1).getNodeType().matches("CC|,")
          || conceptIndex > 0 && conceptIndex < tree.getChildren().size()-1 && tree.getChildren().size() > 2 && tree.getChildren(conceptIndex-1).getNodeType().equals(",") && tree.getChildren(conceptIndex+1).getNodeType().matches("CC|,")){
        // if we meet this simple condition we raise the CONCEPT node!
        // remove old concept node:
        TreebankNode entityRoot = tree.getChildren(conceptIndex).getChildren(0);
        tree.setChildren(conceptIndex, entityRoot);
        entityRoot.setParent(tree);
       
        // insert new concept node:
//        SimpleTree replacementNode = new SimpleTree(tree.cat);
        TreebankNode replacementNode = new TreebankNode(jcas);
        replacementNode.setNodeType(tree.getNodeType());
        replacementNode.setChildren(tree.getChildren());
        for(int i = 0; i < replacementNode.getChildren().size(); i++){
          replacementNode.getChildren(i).setParent(replacementNode);
        }
        replacementNode.setParent(tree);
       
        tree.setNodeType("CONCEPT");
//        tree.children = new ArrayList<SimpleTree>();
        FSArray children = new FSArray(jcas, 1);
        children.set(0, replacementNode);
View Full Code Here

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

  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;
      //            tree = TreeExtractor.getSurroundingTreeWithAnnotation(node, "CONCEPT");
      // navigate up the tree to retrieve the first "S" above this node.
      TreebankNode node = conceptNode;
      while(node.getParent() != null && !node.getNodeType().startsWith("S")){
        node =  node.getParent();
      }

      // get the VP node (clause) or S that most closely dominates the concept, and remove everything after that
      // should smallen the tree while also permitting post-mention negation like "problem resolved" or "problem ruled out"
     
View Full Code Here

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

              break;
            }
          }
          if(!match){
            List<TreebankNode> coveringNodes = JCasUtil.selectCovering(jCas, TreebankNode.class, mention.getBegin(), mention.getEnd());
            TreebankNode smallestCoveringNode = null;
            int smallestLen = Integer.MAX_VALUE;
            for(TreebankNode node : coveringNodes){
              int len = node.getEnd() - node.getBegin();
              if(len <  smallestLen){
                smallestLen = len;
                smallestCoveringNode = node;
              }
            }
            System.out.println("No alignment for: " + mention.getCoveredText());
            System.out.println("  Smallest covering treebank node is: " + (smallestCoveringNode == null ? "null" : smallestCoveringNode.getCoveredText()));
            System.out.println("  " + (smallestCoveringNode == null ? "no tree" : TreeUtils.tree2str(smallestCoveringNode)));
          }
        }
      }
    }
View Full Code Here

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

  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.
      TreebankNode node = conceptNode;
      while(node.getParent() != null && !node.getNodeType().startsWith("S")){
        node =  node.getParent();
      }

//      elevateListConcepts(jcas, node);
     
      // remove nodes to the right of the CONCEPT node
View Full Code Here

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

      if(conceptIndex == 0 && tree.getChildren().size() > 1 && tree.getChildren(1).getNodeType().matches("CC|,")
          || conceptIndex == tree.getChildren().size()-1 && tree.getChildren().size() > 1 && tree.getChildren(conceptIndex-1).getNodeType().matches("CC|,")
          || conceptIndex > 0 && conceptIndex < tree.getChildren().size()-1 && tree.getChildren().size() > 2 && tree.getChildren(conceptIndex-1).getNodeType().equals(",") && tree.getChildren(conceptIndex+1).getNodeType().matches("CC|,")){
        // if we meet this simple condition we raise the CONCEPT node!
        // remove old concept node:
        TreebankNode entityRoot = tree.getChildren(conceptIndex).getChildren(0);
        tree.setChildren(conceptIndex, entityRoot);
        entityRoot.setParent(tree);
       
        // insert new concept node:
//        SimpleTree replacementNode = new SimpleTree(tree.cat);
        TreebankNode replacementNode = new TreebankNode(jcas);
        replacementNode.setNodeType(tree.getNodeType());
        replacementNode.setChildren(tree.getChildren());
        for(int i = 0; i < replacementNode.getChildren().size(); i++){
          replacementNode.getChildren(i).setParent(replacementNode);
        }
        replacementNode.setParent(tree);
       
        tree.setNodeType("CONCEPT");
//        tree.children = new ArrayList<SimpleTree>();
        FSArray children = new FSArray(jcas, 1);
        children.set(0, replacementNode);
View Full Code Here

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

  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;
      //            tree = TreeExtractor.getSurroundingTreeWithAnnotation(node, "CONCEPT");
      // navigate up the tree to retrieve the first "S" above this node.
      TreebankNode node = conceptNode;
      while(node.getParent() != null && !node.getNodeType().startsWith("S")){
        node =  node.getParent();
      }

      // get the VP node (clause) or S that most closely dominates the concept, and remove everything after that
      // should smallen the tree while also permitting post-mention negation like "problem resolved" or "problem ruled out"
     
View Full Code Here

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

  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.
      TreebankNode node = conceptNode;
      while(node.getParent() != null && !node.getNodeType().startsWith("S")){
        node =  node.getParent();
      }

      // remove nodes to the right of the CONCEPT node
      AnnotationTreeUtils.removeRightOfAnnotation(jcas, node, conceptNode);
     
View Full Code Here

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

  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;
      //            tree = TreeExtractor.getSurroundingTreeWithAnnotation(node, "CONCEPT");
      // navigate up the tree to retrieve the first "S" above this node.
      TreebankNode node = conceptNode;
      while(node.getParent() != null && !node.getNodeType().startsWith("S")){
        node =  node.getParent();
      }

      // get the VP node (clause) or S that most closely dominates the concept, and remove everything after that
      // should smallen the tree while also permitting post-mention negation like "problem resolved" or "problem ruled out"
     
View Full Code Here

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

//  }

  public static SimpleTree extractPathTree(TreebankNode t1, TreebankNode t2){
    // swap the ordering if necessary
    if(t1.getBegin() > t2.getBegin()){
      TreebankNode temp = t2;
      t2 = t1;
      t1 = temp;
    }

    // edge cases that don't really make sense....
    // 1) Same tree
    // 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());
View Full Code Here

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

  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;
    }
    if(t1 == t2 || (t1.getBegin() >= t2.getBegin() && t1.getEnd() <= t2.getEnd()) || (t2.getBegin() >= t1.getBegin() && t2.getEnd() <= t1.getEnd())){
      node = sameTree(t1,t2);
    }else{
      TreebankNode lca = getLCA(t1,t2);
      ArrayList<TreebankNode> l1 = getUpwardPath(lca, t1);
      ArrayList<TreebankNode> l2 = getUpwardPath(lca, t2);
      if(lca == null){
        lca = new TopTreebankNode(jcas);
        lca.setNodeType("TOP");
        lca.setChildren(new FSArray(jcas,2));
        if(l1.size()==0){
          l1.add(t1);
        }
        if(l2.size() == 0){
          l2.add(t2);
        }
        lca.setChildren(0, l1.get(0));
        lca.setChildren(1, l2.get(0));
      }
      node = buildSimpleClonePET(lca, t1, t2);
    }
    return node;
  }
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.