Package org.cleartk.classifier

Examples of org.cleartk.classifier.Feature


      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


    //get segment id
    if (segList != null && !segList.isEmpty()){
      for(Segment seg : segList) {
        String segname = seg.getId();
        Feature feature = new Feature("SegmentID", segname);
        feats.add(feature);
      }

    }
    return feats;
View Full Code Here

      }

      //get the closest Time Expression feature
      for (Map.Entry<Integer, TimeMention> entry : timeDistMap.entrySet()) {
        if( entry.getValue().equals(time)){
          Feature indicator = new Feature("ClosestPair", "ClosestPair");
          feats.add(indicator);
          return feats;
        }
        break;
      }
    }

    if (timeSentList != null && !timeSentList.isEmpty()){
      eventDistMap = new TreeMap<Integer, EventMention>();

      for(Sentence sent : timeSentList) {
        for (EventMention aEvent : JCasUtil.selectCovered(jCas, EventMention.class, sent)) {
          eventDistMap.put(Math.abs(aEvent.getBegin() - time.getBegin()), aEvent);
        }
      }

      //get the closest Event feature
      for (Map.Entry<Integer, EventMention> entry : eventDistMap.entrySet()) {
        if( entry.getValue().equals(event)){
          Feature indicator = new Feature("ClosestPair", "ClosestPair");
          feats.add(indicator);
        }
        break;
      }
    }
View Full Code Here

    ArrayList<Feature> features = new ArrayList<Feature>();

    if (idannoList != null && !idannoList.isEmpty())
    {
      features.add(new Feature("TokenInside","A_IdentifiedAnnotation"));
      for (IdentifiedAnnotation ida : idannoList){
        //check if the ida is a know event:
        double[] values = this.textDoublesMap.get(ida.getCoveredText().toLowerCase());
        if(values != null){
          features.add(new Feature(this.name, "is_A_KnownEvent"));
          break;
        }
      }
    }
View Full Code Here

          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));
        }else if(childIndex==0 && rcComma){
          feats.add(new Feature(prefix + "_startlist", true));
        }else if(lcAnd){
          feats.add(new Feature(prefix + "_endlist", true));
        }
       
        if(lcComma || rcComma || lcAnd){
          // somehow in a list
          // check to see if any element of the list is already part of a relation
          for(BinaryTextRelation otherRel : JCasUtil.select(jCas, BinaryTextRelation.class)){
            Annotation a1 = otherRel.getArg1().getArgument();
            Annotation a2 = otherRel.getArg2().getArgument();
            if(a1 instanceof TimeMention || a2 instanceof TimeMention) continue; // covered by another feature
            if(priorNPs.contains(getKey(a1))){
              // one of the left children is already in another relation!
              feats.add(new Feature(prefix + "_leftSiblingInRelation", true));
             
              // check if the other argument in that relation is the secondary arg
              if(secondArg.getBegin() == a2.getBegin() && secondArg.getEnd() == a2.getEnd()){
                // the other proposed arg of this relation is already in a relation with another element of this list!
                feats.add(new Feature(prefix + "_leftSiblingInRelationWithCurArg"));
              }
            }
           
            if(priorNPs.contains(getKey(a2))){
              feats.add(new Feature(prefix + "_leftSiblingInRelation", true));
             
              if(secondArg.getBegin() == a1.getBegin() && secondArg.getEnd() == a1.getEnd()){
                // the other proposed arg of this relation is already in a relation with another element of this list!
                feats.add(new Feature(prefix + "_leftSiblingInRelationWithCurArg"));
              }
            }
          }
        }
      }
View Full Code Here

    List<Feature> feats = Lists.newArrayList();
   
    if(arg1 instanceof EventMention){
      List<Predicate> preds = JCasUtil.selectCovered(Predicate.class, arg1);
      if(preds.size() > 0){
        feats.add(new Feature("Arg1_Pred", true));
        feats.add(new Feature("Arg1_Frame", preds.get(0).getFrameSet()));
        // check if arg2 is one of its SRL args
        FSList relList = preds.get(0).getRelations();
        while(relList instanceof NonEmptyFSList){
          SemanticRoleRelation rel = (SemanticRoleRelation) ((NonEmptyFSList)relList).getHead();
          SemanticArgument arg = rel.getArgument();
          if(arg.getBegin() == arg2.getBegin() && arg.getEnd() == arg2.getEnd()){
            feats.add(new Feature("Arg1_Pred_Arg2_Role", true));
            break;
          }
          relList = ((NonEmptyFSList)relList).getTail();
        }
      }
      List<SemanticArgument> args = JCasUtil.selectCovered(SemanticArgument.class, arg1);
      if(args.size() > 0){
        feats.add(new Feature("Arg1_SemArg", true));
        feats.add(new Feature("Arg1_SemArgType", args.get(0).getLabel()));
      }
    }
   
    if(arg2 instanceof EventMention){
      List<Predicate> preds = JCasUtil.selectCovered(Predicate.class, arg2);
      if(preds.size() > 0){
        feats.add(new Feature("Arg2_Pred", true));
        feats.add(new Feature("Arg2_Frame", preds.get(0).getFrameSet()));
        // check if arg2 is one of its SRL args
        FSList relList = preds.get(0).getRelations();
        while(relList instanceof NonEmptyFSList){
          SemanticRoleRelation rel = (SemanticRoleRelation) ((NonEmptyFSList)relList).getHead();
          SemanticArgument arg = rel.getArgument();
          if(arg.getBegin() == arg1.getBegin() && arg.getEnd() == arg1.getEnd()){
            feats.add(new Feature("Arg2_Pred_Arg1_Role", true));
            break;
          }
          relList = ((NonEmptyFSList)relList).getTail();
        }
      }
      List<SemanticArgument> args = JCasUtil.selectCovered(SemanticArgument.class, arg2);
      if(args.size() > 0){
        feats.add(new Feature("Arg2_SemArg", true));
        feats.add(new Feature("Arg2_SemArgType", args.get(0).getLabel()));
      }
    }
   
    return feats;
  }
View Full Code Here

      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

      throws CleartkExtractorException {
    List<Feature> features = Lists.newArrayList();
    for (Predicate predicate : JCasUtil.selectCovered(view, Predicate.class, focusAnnotation)) {
      String category = this.frameSetCategories.get(predicate.getFrameSet());
      if (category != null) {
        features.add(new Feature("FramesetCategory", category));
      }
    }
    return features;
  }
View Full Code Here

    }
    events = realEvents;
    EventMention anchor = events.get(0);
   
    if(arg1.getBegin() == anchor.getBegin() && arg1.getEnd() == anchor.getEnd()){
      feats.add(new Feature("Arg1LeftmostEvent"));
    }else if(arg2.getBegin() == anchor.getBegin() && arg2.getEnd() == anchor.getEnd()){
      feats.add(new Feature("Arg2LeftmostEvent"));
    }
   
    if(arg1 instanceof EventMention){
      feats.addAll(getEventFeats("mention1property", (EventMention)arg1));
    }
View Full Code Here

   }

  private static Collection<? extends Feature> getEventFeats(String name, EventMention mention) {
    List<Feature> feats = new ArrayList<Feature>();
   
    feats.add(new Feature(name + "_modality", mention.getEvent().getProperties().getContextualModality()));
    feats.add(new Feature(name + "_aspect", mention.getEvent().getProperties().getContextualAspect()));
    feats.add(new Feature(name + "_permanence", mention.getEvent().getProperties().getPermanence()));
    feats.add(new Feature(name + "_polarity", mention.getEvent().getProperties().getPolarity()));
    feats.add(new Feature(name + "_category", mention.getEvent().getProperties().getCategory()));
    feats.add(new Feature(name + "_degree", mention.getEvent().getProperties().getDegree()));
    feats.add(new Feature(name + "_doctimerel", mention.getEvent().getProperties().getDocTimeRel()));
   
    return feats;
  }
View Full Code Here

TOP

Related Classes of org.cleartk.classifier.Feature

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.