@Override protected String classify(List<Feature> features) throws CleartkProcessingException { numClassifications++; String category = super.classifier.classify(features); if(this.scoreAll){ Map<String,Double> scores = super.classifier.score(features); this.lastScore = scores.get(IDENTITY_RELATION); category = IDENTITY_RELATION; } return category; }
@Override protected String classify(List<Feature> features) throws CleartkProcessingException { numClassifications++; String category = super.classifier.classify(features); if(this.scoreAll){ Map<String,Double> scores = super.classifier.score(features); this.lastScore = scores.get(IDENTITY_RELATION); category = IDENTITY_RELATION; } return category; }
private Map<OUTCOME_TYPE, Double> getScoredOutcomes(List<Feature> features, Path path) throws CleartkProcessingException { // add the features from preceding outcomes features = Lists.newArrayList(features); if (path != null) { List<Object> previousOutcomes = new ArrayList<Object>(path.outcomes); for (OutcomeFeatureExtractor outcomeFeatureExtractor : this.outcomeFeatureExtractors) { features.addAll(outcomeFeatureExtractor.extractFeatures(previousOutcomes)); } } // get the scored outcomes for this instance Map<OUTCOME_TYPE, Double> scoredOutcomes = this.delegatedClassifier.score(features); if (scoredOutcomes.isEmpty()) { throw new IllegalStateException("expected at least one scored outcome, found " + scoredOutcomes); } return scoredOutcomes; }
@Override public void process(JCas jcas) throws AnalysisEngineProcessException { LOGGER.info( "Processing ..." ); for(Markable markable : JCasUtil.select(jcas, Markable.class)){ boolean outcome; List<Feature> features = new ArrayList<>(); for(FeatureExtractor1<Markable> extractor : extractors){ features.addAll(extractor.extract(jcas, markable)); } Instance<Boolean> instance = new Instance<>(features); if(this.isTraining()){ outcome = markable.getConfidence() > 0.5; instance.setOutcome(outcome); this.dataWriter.write(instance); }else{ Map<Boolean,Double> outcomes = this.classifier.score(features); markable.setConfidence(outcomes.get(true).floatValue()); } } LOGGER.info( "Finished." ); } }
@Override public void process(JCas jcas) throws AnalysisEngineProcessException { for(Markable markable : JCasUtil.select(jcas, Markable.class)){ boolean outcome; List<Feature> features = new ArrayList<>(); for(FeatureExtractor1<Markable> extractor : extractors){ features.addAll(extractor.extract(jcas, markable)); } Instance<Boolean> instance = new Instance<>(features); if(this.isTraining()){ outcome = markable.getConfidence() > 0.5; instance.setOutcome(outcome); this.dataWriter.write(instance); }else{ Map<Boolean,Double> outcomes = this.classifier.score(features); markable.setConfidence(outcomes.get(true).floatValue()); } } } }
@Override public void process(JCas jcas) throws AnalysisEngineProcessException { for (Sentence sentence : JCasUtil.select(jcas, Sentence.class)) { Instance<Boolean> instance = new Instance<Boolean>(false, this.extractor.extract( jcas, sentence)); if (this.isTraining()) { this.dataWriter.write(instance); } else { Map<Boolean, Double> scoredOutcomes = this.classifier.score(instance.getFeatures()); Double trueScore = scoredOutcomes.get(true); if (trueScore > 0.0) { SummarySentence extractedSentence = new SummarySentence( jcas, sentence.getBegin(), sentence.getEnd()); extractedSentence.setScore(trueScore); extractedSentence.addToIndexes(); } } } }
Map<String, Double> scores = this.classifier.score( features );
String predictedCategory = this.classify(features); Map<String,Double> scores = this.classifier.score(features);