Package org.apache.ctakes.typesystem.type.syntax

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


    if(sems == null){
      sems = new SemanticClasses(FileLocator.locateFile("org/apache/ctakes/assertion/models/semantic_classes").getAbsolutePath());
    }
    Collection<IdentifiedAnnotation> mentions = JCasUtil.select(jcas, IdentifiedAnnotation.class);
    for(IdentifiedAnnotation mention : mentions){
      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);
View Full Code Here


    }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);
        }
View Full Code Here

      return;
    }
    FSIterator<Annotation> iterator = jcas.getAnnotationIndex(TopTreebankNode.type).iterator();
   
    while(iterator.hasNext()){
      TopTreebankNode node = (TopTreebankNode) iterator.next();
      out.println(node.getTreebankParse());
    }
    out.flush();
  }
View Full Code Here

    }
    if(parse == null){
      buff.append("(S null)");
    }

    TopTreebankNode ttn = new TopTreebankNode(jcas);
    ttn.setTreebankParse(buff.toString());
    ttn.addToIndexes();
  }
View Full Code Here

  // Returns Path-enclosed trees of Moschitti 2004 (ACL)
  @Override
  public List<Feature> extract(JCas jcas, IdentifiedAnnotation arg1, IdentifiedAnnotation arg2) throws AnalysisEngineProcessException {
    List<Feature> features = new ArrayList<Feature>();
    // first get the root and print it out...
    TopTreebankNode root = AnnotationTreeUtils.getTreeCopy(jcas, AnnotationTreeUtils.getAnnotationTree(jcas, arg1));
   
//    SimpleTree tempClone = TreeExtractor.getSimpleClone(root);
//    features.add(new Feature("TK_FULL", tempClone.toString()));
    TreebankNode t1 = AnnotationTreeUtils.insertAnnotationNode(jcas, root, arg1, "ARG1");
    TreebankNode t2 = AnnotationTreeUtils.insertAnnotationNode(jcas, root, arg2, "ARG2");
View Full Code Here

  @Override
  public List<Feature> extract(JCas jcas, IdentifiedAnnotation arg1,
      IdentifiedAnnotation arg2) throws AnalysisEngineProcessException {
    List<Feature> features = new ArrayList<Feature>();
    // first get the root and print it out...
    TopTreebankNode root = AnnotationTreeUtils.getTreeCopy(jcas, AnnotationTreeUtils.getAnnotationTree(jcas, arg1));
//    SimpleTree tempClone = TreeExtractor.getSimpleClone(root);
    TreebankNode t1 = AnnotationTreeUtils.insertAnnotationNode(jcas, root, arg1, "ARG1");
    TreebankNode t2 = AnnotationTreeUtils.insertAnnotationNode(jcas, root, arg2, "ARG2");

    SimpleTree tree = null;
View Full Code Here

    ttn = getRoot(n).getTerminals(headIndex);
    return ttn;
  }
 
  public static TopTreebankNode getRoot(TreebankNode n){
    TopTreebankNode ret = null;
    while(!(n instanceof TopTreebankNode)){
      n = n.getParent();
    }
    ret = (TopTreebankNode) n;
    return ret;
View Full Code Here


public class AnnotationTreeUtils {
 
  public static TopTreebankNode getAnnotationTree(JCas jcas, Annotation annot){
    TopTreebankNode tree = null;
//    FSIterator<Annotation> iter = jcas.getJFSIndexRepository().getAnnotationIndex(TopTreebankNode.type).iterator();
    Collection<TopTreebankNode> roots = JCasUtil.select(jcas, TopTreebankNode.class);
//    while(iter.hasNext()){
    for(TopTreebankNode root : roots){
//      TopTreebankNode root = (TopTreebankNode) iter.next();
View Full Code Here

    return tree;
  }

  public static TopTreebankNode getTreeCopy(JCas jcas, TopTreebankNode orig){
    if(orig == null) return null;
    TopTreebankNode copy = new TopTreebankNode(jcas);
    copy.setNodeType(orig.getNodeType());
    copy.setBegin(orig.getBegin());
    copy.setEnd(orig.getEnd());
    copy.setParent(null);
    copy.setChildren(new FSArray(jcas,1));
    copy.setTreebankParse(orig.getTreebankParse());
    if(orig.getChildren() == null || orig.getChildren().size() == 0){
      System.err.println("WHAT?");
    }
    copy.setChildren(0, getTreeCopy(jcas, orig.getChildren(0)));
    copy.getChildren(0).setParent(copy);
    return copy;
  }
View Full Code Here

    ttn = getRoot(n).getTerminals(headIndex);
    return ttn;
  }
 
  public static TopTreebankNode getRoot(TreebankNode n){
    TopTreebankNode ret = null;
    while(!(n instanceof TopTreebankNode)){
      n = n.getParent();
    }
    ret = (TopTreebankNode) n;
    return ret;
View Full Code Here

TOP

Related Classes of org.apache.ctakes.typesystem.type.syntax.TopTreebankNode

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.