Package org.cleartk.classifier

Examples of org.cleartk.classifier.Feature


      return features;
    }
   
    Map<String, Float> distribution = textToDistribution.get(eventText);
    if(distribution == null) {
      features.add(new Feature("no_duration_info"));
    } else {
      for(String timeUnit : distribution.keySet()) {
        features.add(new Feature("duration_" + timeUnit, distribution.get(timeUnit)))
      }
    }
   
    return features;
  }
View Full Code Here


     
      // print out totals:
      for(String typeId : typeCounts.keySet()){
        String featName = "arg1EntityTypeID_"+typeId;
        arg1Types.add(featName);
        features.add(new Feature(featName, typeCounts.get(typeId)));       
      }
     
      // TO print out just the types without counts:
//      for(String typeId : typeCounts.keySet()){
//        features.add(new Feature("arg1EntityTypeID_", typeId));
//      }
     
      // TODO: this is the correct implementatino, but it does not perform as well
//      for(int typeID : uniqueTypeIDs) {
//        features.add(new Feature("arg1EntityTypeID", String.valueOf(typeID)));
//      }

    }

    if(arg2 instanceof EventMention){
      CounterMap<String> typeCounts =
          getMentionTypes(JCasUtil.selectCovering(systemView, EventMention.class, arg2.getBegin(), arg2.getEnd()));
     
      // print out totals:
      for(String typeId : typeCounts.keySet()){
        String featName = "arg2EntityTypeID_"+typeId;
        arg2Types.add(featName);
        features.add(new Feature(featName, typeCounts.get(typeId)));       
      }     
    }
   
    if(arg1Types.size() == 0) arg1Types.add("arg1NotUMLS");
    if(arg2Types.size() == 0) arg2Types.add("arg2NotUMLS");
    for(String arg1Type : arg1Types){
      for(String arg2Type : arg2Types){
        features.add(new Feature("ArgPair-" + arg1Type + "_" + arg2Type));
      }
    }
    return features;
  }
View Full Code Here

      return features;
    }
   
    Map<String, Float> eventDistribution = textToDistribution.get(eventText);
    if(eventDistribution == null) {
      features.add(new Feature("no_duration_info"));
      return features;
    }
   
    float expectation = Utils.expectedDuration(eventDistribution);
    features.add(new Feature("expected_duration", expectation));
   
    for(String bin : Utils.bins) {
      features.add(new Feature(bin, eventDistribution.get(bin)));
    }

    String largestBin = null;
    float largestValue = 0f;
    for(String bin : Utils.bins) {
      if(eventDistribution.get(bin) > largestValue) {
        largestBin = bin;
        largestValue = eventDistribution.get(bin);
      }
    }
    features.add(new Feature("largest_bin_" + largestBin));
   
    return features;
  }
View Full Code Here

        values = this.meanValues;
      }

      for (int i = 0; i < values.length; ++i) {
        String featureName = Feature.createName(this.name, String.valueOf(i));
        features.add(new Feature(featureName, values[i]));
      }
    }
    return features;
  }
View Full Code Here

    }
   
    Map<String, Float> arg1Distribution = textToDistribution.get(arg1text);
    if(arg1Distribution == null) {
      // this shouldn't happen if relations with no durations for args filtered out
      features.add(new Feature("arg1_no_duration_info"));
      return features;
    }
   
    expectedDuration1 = Utils.expectedDuration(arg1Distribution);
   
    Map<String, Float> arg2Distribution = textToDistribution.get(arg2text);
    if(arg2Distribution == null) {
      // this shouldn't happen if relations with no durations for args filtered out
      features.add(new Feature("arg2_no_duration_info"));
      return features;
    }
   
    expectedDuration2 = Utils.expectedDuration(arg2Distribution);
    features.add(new Feature("expected_duration_difference", expectedDuration1 - expectedDuration2));
    return features;
  }
View Full Code Here

    TimeMention time = null;

    if(arg1 instanceof EventMention){
      event = JCasUtil.selectCovering(jCas, EventMention.class, arg1.getBegin(), arg1.getEnd()).get(0);
      if( event != null && event.getEvent() !=null ){
        feats.add(new Feature("Arg1-Event-Modality", event.getEvent().getProperties().getContextualModality()));
      }
    }else if(arg1 instanceof TimeMention){
      time = (TimeMention) arg1;
      if( time != null){
        feats.add(new Feature("Arg1-Timex-", time.getTimeClass()));
      }     
    }

    if(arg2 instanceof TimeMention){
      time = (TimeMention) arg2;
      if(time != null){
        feats.add(new Feature("Arg2-Timex-", time.getTimeClass()));
      }
    }else if(arg2 instanceof EventMention){
      event = JCasUtil.selectCovering(jCas, EventMention.class, arg2.getBegin(), arg2.getEnd()).get(0);
      if(event !=null && event.getEvent() !=null ){
        feats.add(new Feature("Arg2-Event-Modality", event.getEvent().getProperties().getContextualModality()));
      }
    }

    return feats;
  }
View Full Code Here

        cumulativeProbability = cumulativeProbability + eventDistribution.get(bin);
        break;
      }
      cumulativeProbability = cumulativeProbability + eventDistribution.get(bin);
    }
    features.add(new Feature("cumulative_probability", cumulativeProbability));
   
    return features;
  }
View Full Code Here

    List<Feature> features = new ArrayList<Feature>();
    String timeText = arg2.getCoveredText().toLowerCase()// arg2 is a time mention

    Set<TemporalUnit> units = Utils.runTimexParser(timeText);
    if(units == null) {
      features.add(new Feature("failed_normalization", true));
      return features;
    }
   
    scala.collection.Iterator<TemporalUnit> iterator = units.iterator();
    while(iterator.hasNext()) {
      TemporalUnit unit = iterator.next();
      String coarseTimeUnit = Utils.putInBin(unit.getName());
     
      if(coarseTimeUnit == null) {
        features.add(new Feature("failed_normalization", true));
        return features;
      }
     
      Map<String, Float> distribution = Utils.convertToDistribution(coarseTimeUnit);
      float timeExpectedDuration = Utils.expectedDuration(distribution);
      features.add(new Feature("time_duration", timeExpectedDuration));
    }

    return features;
  }
View Full Code Here

   
    //1 get event:
    EventMention event = (EventMention)annotation;
    String contextModal = event.getEvent().getProperties().getContextualModality();
    if ( "GENERIC".equals(contextModal) ){
      Feature contexmod = new Feature(this.name, contextModal);
      features.add(contexmod);
//      logger.info("found a event: "+ contextModal);
    }
   
    return features;
View Full Code Here

    List<Feature> features = Lists.newArrayList();
    int begin = Math.max(tokenIndex - nBefore, 0);
    int end = Math.min(tokenIndex + nAfter + 1, this.subChunkLabels.size());
    for (int i = begin; i < end; ++i) {
      String featureName = String.format("%s_%d", this.name, i - begin - nBefore);
      features.add(new Feature(featureName, this.subChunkLabels.get(i)));
    }
    return features;
  }
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.