Beispiel #1
0
void
DefaultCandidateSetScorer::Score(Model *model,
                                 CandidateSet &candidates, bool training) {
  // N.B.: We assume there is at least one candidate!
  CandidateSet::iterator it = candidates.begin();

  // Score first candidate, which is perforce the best candidate so far.
  model->ScoreCandidate(*(*it), training);

  CandidateSet::iterator best_it = it;
  CandidateSet::iterator gold_it = it;
  ++it;

  // Score any and all remaining candidates.
  for ( ; it != candidates.end(); ++it) {
    Candidate &candidate = *(*it);
    model->ScoreCandidate(candidate, training);
    if (model->score_comparator()->Compare(*model, candidate, **best_it) > 0) {
      best_it = it;
    }
    if (model->gold_comparator()->Compare(*model, candidate, **gold_it) > 0) {
      gold_it = it;
    }
  }
  candidates.set_best_scoring_index((*best_it)->index());
  candidates.set_gold_index((*gold_it)->index());
}