Package org.cleartk.classifier

Examples of org.cleartk.classifier.Feature


  private Collection<? extends Feature> hashToFeatureList(
      HashMap<String, Boolean> featsIn) {
   
    Collection<Feature> featsOut = new HashSet<Feature>();
    for (String featName : featsIn.keySet()) {
      featsOut.add(new Feature(featName,featsIn.get(featName)));
    }
   
    return featsOut;
  }
View Full Code Here


    List<Feature> features = new ArrayList<Feature>();
   
    // Pull in general dependency-based features -- externalize to another extractor?
      ConllDependencyNode node = DependencyUtility.getNominalHeadNode(jCas, arg);
      if (node!= null) {
        features.add(new Feature("DEPENDENCY_HEAD", node.getCoveredText()));
        features.add(new Feature("DEPENDENCY_HEAD_deprel", node.getDeprel()));
    }
     
      HashMap<String, Boolean> featsMap = SubjectAttributeClassifier.extract(jCas, arg);

      if (!featsMap.isEmpty()) {
        // Pull in all the features that were used for the rule-based module
        features.addAll( hashToFeatureList(featsMap) );
        // Pull in the result of the rule-based module as well
        features.add(new Feature("SUBJECT_CLASSIFIER_LOGIC", SubjectAttributeClassifier.classifyWithLogic(featsMap)));
      }
     
      return features;
  }
View Full Code Here

  private Collection<? extends Feature> hashToFeatureList(
      HashMap<String, Boolean> featsIn) {
   
    Collection<Feature> featsOut = new HashSet<Feature>();
    for (String featName : featsIn.keySet()) {
      featsOut.add(new Feature(featName,featsIn.get(featName)));
    }
   
    return featsOut;
  }
View Full Code Here

      tree = TreeExtractor.getSimpleClone(t2);
    }else{
      tree = TreeExtractor.extractPathEnclosedTree(t1, t2, jcas);
    }

    features.add(new Feature("TK_PET", tree.toString()));
    return features;
  }
View Full Code Here

    List<Feature> features = new ArrayList<Feature>();
   
    // entity1 ... entity2 scenario
    if(arg1.getEnd() < arg2.getBegin()) {
      features.add(new Feature("arg1_arg2", true));
    }
   
    // entity2 ... entity1 scenario
    if(arg2.getEnd() < arg1.getBegin()) {
      features.add(new Feature("arg2_arg1", true));
    }
   
    return features;
  }
View Full Code Here

       
    // Extract features between
    List<TerminalTreebankNode> headList = this.extractPhraseHeadByTreenode(jCas, JCasUtil.selectCovered(jCas, TreebankNode.class, arg1.getEnd(), arg2.getBegin()));

    if(headList.size() > 0) {
      features.add(new Feature("PhraseChunk_Between_FirstHead", headList.get(0).getNodeValue()));
      features.add(new Feature("PhraseChunk_Between_LastHead", headList.get(headList.size()-1).getNodeValue()));
     
      if(headList.size() >= 2) {
        String inBetweenValue = "";
        for(int i=1;i<headList.size()-1;i++) {
          if(i>1)
            inBetweenValue += "_";
          inBetweenValue += headList.get(i).getNodeValue();
        }
        features.add(new Feature("PhraseChunk_Between_BetweenHeads", inBetweenValue));
      }
    }
   
    // Extract feature before M1
    headList = this.extractPhraseHeadByTreenode(jCas, JCasUtil.selectPreceding(jCas, TreebankNode.class, arg1, 20));

    boolean isFirst = false;
    for(int i=headList.size()-1;i>=0;i--) {
      if(headList.get(i).getEnd() < arg1.getBegin()) {
        if(!isFirst) {
        features.add(new Feature("PhraseChunk_Before_FirstHead", headList.get(i).getNodeValue()));
        isFirst = true;
        }
        else {
          features.add(new Feature("PhraseChunk_Before_SecondHead", headList.get(i).getNodeValue()));
          break;
        }
      }
    }
   
    // Extract feature after M2
    headList = this.extractPhraseHeadByTreenode(jCas, JCasUtil.selectFollowing(jCas, TreebankNode.class, arg2, 20));
   
   
    isFirst = false;
    for(int i=0;i<headList.size();i++) {
      if(headList.get(i).getBegin() > arg2.getEnd() ) {
        if(!isFirst) {
          features.add(new Feature("PhraseChunk_After_FirstHead", headList.get(i).getNodeValue()));
          isFirst = true;
        }
        else {
          features.add(new Feature("PhraseChunk_After_SecondHead", headList.get(i).getNodeValue()));
          break;
        }
      }
    }
   
View Full Code Here

    features.addAll(this.nEntityMentionsBetween.extract(jCas, arg1, arg2));

    // entity type of both mentions, concatenated
    int type1 = arg1.getTypeID();
    int type2 = arg2.getTypeID();
    features.add(new Feature("type1type2", String.format("%s_%s", type1, type2)));

    // is mention1 included in mention2?
    boolean begins1After2 = arg1.getBegin() >= arg2.getBegin();
    boolean ends1Before2 = arg1.getEnd() <= arg2.getEnd();
    features.add(new Feature("mention1InMention2", begins1After2 && ends1Before2));

    // is mention2 included in mention1?
    boolean begins2After1 = arg2.getBegin() >= arg1.getBegin();
    boolean ends2Before1 = arg2.getEnd() <= arg1.getEnd();
    features.add(new Feature("mention2InMention1", begins2After1 && ends2Before1));

    return features;
  }
View Full Code Here

      tree = TreeExtractor.extractPathEnclosedTree(t1, t2, jcas);
    }

    for(SimpleTree frag : frags){
      if(TreeUtils.containsIgnoreCase(tree, frag)){
        features.add(new Feature("TK_" + frag.toString()));
        //      }else{
        //        features.add(new Feature(frag.toString(), false));
      }
    }
View Full Code Here

            closest = tokens.size();
          }
//          instance.addAll(cuePhraseInWindowExtractor.extractBetween(jCas, cue, entityOrEventMention));
        }
        if(closestCue != null && closest < 21){
          instance.add(new Feature("ClosestCue_Word", closestCue.getCoveredText()));
//          instance.add(new Feature("ClosestCue_Phrase", closestCue.getCuePhrase()));
          instance.add(new Feature("ClosestCue_PhraseFamily", closestCue.getCuePhraseAssertionFamily()));
          instance.add(new Feature("ClosestCue_PhraseCategory", closestCue.getCuePhraseCategory()));
        }
      }
//      if (cuePhraseFeatures != null && !cuePhraseFeatures.isEmpty())
//      {
//        instance.addAll(cuePhraseFeatures);
//      }


      // 7/9/13 SRH trying to make it work just for anatomical site
      int eemTypeId = entityOrEventMention.getTypeID();
      if (eemTypeId == CONST.NE_TYPE_ID_ANATOMICAL_SITE) {
          // 7/9/13 srh modified per tmiller so it's binary but not numeric feature
          //instance.add(new Feature("ENTITY_TYPE_" + entityOrEventMention.getTypeID()));
          instance.add(new Feature("ENTITY_TYPE_ANAT_SITE"));
      } /* This hurts recall more than it helps precision
      else if (eemTypeId == CONST.NE_TYPE_ID_DRUG) {
        // 7/10 adding drug
        instance.add(new Feature("ENTITY_TYPE_DRUG"));
      }
View Full Code Here

    }
   
    ArrayList<Feature> featureList = new ArrayList<Feature>();
    for (Zone zone : zoneList)
    {
      Feature currentFeature = new Feature("zone", zone.getLabel());
      logger.debug(String.format("zone: %s", zone.getLabel()));
      logger.debug(String.format("zone feature: %s", currentFeature.toString()));
      featureList.add(currentFeature);
    }
   
    return featureList;
  }
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.