Package org.cleartk.classifier

Examples of org.cleartk.classifier.TreeFeature


    // first get the root and print it out...
    TopTreebankNode root = AnnotationTreeUtils.getTreeCopy(view, AnnotationTreeUtils.getAnnotationTree(view, focusAnnotation));

    if(root == null){
      SimpleTree fakeTree = new SimpleTree("(S (NN null))");
      features.add(new TreeFeature(FEAT_NAME, fakeTree.toString()));
      return features;
    }


    String etype="";
    String eventModality="";

    if(focusAnnotation instanceof EventMention){
      eventModality = ((EventMention)focusAnnotation).getEvent().getProperties().getContextualModality();
      etype = "EVENT-"+eventModality;
      AnnotationTreeUtils.insertAnnotationNode(view, root, focusAnnotation, etype);
    }
 
    SimpleTree tree = null;
    tree = TreeExtractor.getSimpleClone(root);

    TemporalPETExtractor.moveTimexDownToNP(tree);

    features.add(new TreeFeature(FEAT_NAME, tree.toString()));
    return features;
  }
View Full Code Here


    List<Feature> features = new ArrayList<Feature>();
    // first get the root and print it out...
    TopTreebankNode root = AnnotationTreeUtils.getTreeCopy(jcas, AnnotationTreeUtils.getAnnotationTree(jcas, arg1));
    if(root == null){
      SimpleTree fakeTree = new SimpleTree("(S (NN null))");
      features.add(new TreeFeature("TK_PATH", fakeTree.toString()));
      return features;
    }
    // swap the order if necessary:
    if(arg2.getBegin() <= arg1.getBegin() && arg2.getEnd() <= arg1.getEnd()){
      IdentifiedAnnotation temp = arg1;
      arg1 = arg2;
      arg2 = temp;
    }
   
    String a1type="", a2type="";
    String eventModality="";
    String timeClass="";

    if(arg1 instanceof EventMention){
      EventMention mention = (EventMention) arg1;
      if(mention.getEvent() != null && mention.getEvent().getProperties() != null){
        eventModality = mention.getEvent().getProperties().getContextualModality();
      }
      a1type = "EVENT-"+eventModality;
    }else if(arg1 instanceof TimeMention){
      timeClass = ((TimeMention)arg1).getTimeClass();
      a1type = "TIMEX-"+timeClass;
    }
   
    if(arg2 instanceof EventMention){
      EventMention mention = (EventMention) arg2;
      if(mention.getEvent() != null && mention.getEvent().getProperties() != null){
        eventModality = mention.getEvent().getProperties().getContextualModality();
      }
      a2type = "EVENT"+eventModality;     
    }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()));
    return features;
  }
View Full Code Here

    // first get the root and print it out...
    TopTreebankNode root = AnnotationTreeUtils.getTreeCopy(jcas, AnnotationTreeUtils.getAnnotationTree(jcas, arg1));
   
    if(root == null){
      SimpleTree fakeTree = new SimpleTree("(S (NN null))");
      features.add(new TreeFeature(FEAT_NAME, fakeTree.toString()));
      return features;
    }
   
    // swap the order if necessary:
    if(arg2.getBegin() <= arg1.getBegin() && arg2.getEnd() <= arg1.getEnd()){
      IdentifiedAnnotation temp = arg1;
      arg1 = arg2;
      arg2 = temp;
    }
   
    String a1type="", a2type="";
    String eventModality="";
    String timeClass;
   
    if(arg1 instanceof EventMention){
      eventModality = ((EventMention)arg1).getEvent().getProperties().getContextualModality();
      a1type = "EVENT-"+eventModality;
    }else if(arg1 instanceof TimeMention){
      timeClass = ((TimeMention)arg1).getTimeClass();
      a1type = "TIMEX-"+timeClass;
    }
   
    if(arg2 instanceof EventMention){
      eventModality = ((EventMention)arg2).getEvent().getProperties().getContextualModality();
      a2type = "EVENT-"+eventModality;     
    }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);
    }

    TemporalPETExtractor.moveTimexDownToNP(tree);
   
    features.add(new TreeFeature(FEAT_NAME, tree.toString()));
    return features;
  }
View Full Code Here

    // first get the root and print it out...
    TopTreebankNode root = AnnotationTreeUtils.getTreeCopy(jcas, AnnotationTreeUtils.getAnnotationTree(jcas, arg1));
   
    if(root == null){
      SimpleTree fakeTree = new SimpleTree("(S (NN null))");
      features.add(new TreeFeature("TK_PET", fakeTree.toString()));
      return features;
    }
   
    // swap the order if necessary:
    if(arg2.getBegin() <= arg1.getBegin() && arg2.getEnd() <= arg1.getEnd()){
      IdentifiedAnnotation temp = arg1;
      arg1 = arg2;
      arg2 = temp;
    }
   
    String a1type="", a2type="";
    String eventModality="";
    String timeClass;
   
    if(arg1 instanceof EventMention){
      EventMention mention = (EventMention) arg1;
      if(mention.getEvent() != null && mention.getEvent().getProperties() != null){
        eventModality = mention.getEvent().getProperties().getContextualModality();
      }
      a1type = "EVENT-"+eventModality;
    }else if(arg1 instanceof TimeMention){
      timeClass = ((TimeMention)arg1).getTimeClass()
      a1type = "TIMEX-"+timeClass;
    }
   
    if(arg2 instanceof EventMention){
      EventMention mention = (EventMention) arg2;
      if(mention.getEvent() != null && mention.getEvent().getProperties() != null){
        eventModality = mention.getEvent().getProperties().getContextualModality();
      }
      a2type = "EVENT-"+eventModality;     
    }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.setGeneralizeLeaf(true);
    moveTimexDownToNP(tree);
    simplifyGCG(tree);
   
    features.add(new TreeFeature("TK_PET", tree.toString()));
    return features;
  }
View Full Code Here

        dtreeStr = headTree.toString();
      }
      break;
    }
   
    features.add(new TreeFeature(FEAT_NAME, dtreeStr));
    return features;
  }
View Full Code Here

    }
   
    SimpleTree bopTree = getTree(jcas, arg1, arg2, "BOP", new Function<BaseToken,String>(){public String apply(BaseToken t){ return t.getPartOfSpeech();}});
    SimpleTree bowTree = getTree(jcas, arg1, arg2, "BOW", new Function<BaseToken,String>(){public String apply(BaseToken t){ return t.getCoveredText();}});
   
    feats.add(new TreeFeature("TK_BOP_Tree", bopTree.toString()));
    feats.add(new TreeFeature("TK_BOW_Tree", bowTree.toString()));
    return feats;
  }
View Full Code Here

  @Override
  public List<Feature> extract(JCas jcas, Annotation annotation)
      throws CleartkExtractorException {
    List<Feature> features = new ArrayList<Feature>();
    SimpleTree tree = extractAboveLeftConceptTree(jcas, annotation, sems);
    features.add(new TreeFeature("TK_AboveLeftTree", tree.toString()));
    return features;
  }
View Full Code Here

 
  @Override
  public List<Feature> extract(JCas jCas, Annotation arg1)
      throws CleartkExtractorException {
    List<Feature> feats = Lists.newArrayList();
    TreeFeature f1 = null;
    String treeString = null;
   
    List<Sentence> sents = JCasUtil.selectCovering(jCas, Sentence.class, arg1.getBegin(), arg1.getEnd());
    if(sents == null || sents.size() == 0){
      treeString = "(S (no parse))";
    }else{
      Sentence sent = sents.get(0);
      List<ConllDependencyNode> nodes = JCasUtil.selectCovered(ConllDependencyNode.class, sent);
   
      //treeString = AnnotationDepUtils.getTokenRelTreeString(jCas, nodes, new Annotation[]{arg1}, new String[]{"CONCEPT"}, true);
//      treeString = AssertionDepUtils.getTokenRelTreeString(jCas, nodes, arg1, "CONCEPT");
      SimpleTree tree = AssertionDepUtils.getTokenTreeString(jCas, nodes, arg1, GenerateDependencyRepresentation.UP_NODES);
     
      if(tree == null){
        treeString = "(S (no parse))";
      }else{
        AssertionTreeUtils.replaceDependencyWordsWithSemanticClasses(tree, sems);
        treeString = tree.toString();
//        treeString = treeString.replaceAll("\\(([^ ]+) \\)", "$1");
      }
    }

    f1 = new TreeFeature("TK_DW", treeString);  
    feats.add(f1);
    return feats;
  }
View Full Code Here

TOP

Related Classes of org.cleartk.classifier.TreeFeature

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.