src/classify/shapeclassifier.cpp
int ShapeClassifier::BestShapeForUnichar(const TrainingSample &sample, Image page_pix,
                                         UNICHAR_ID unichar_id, ShapeRating *result) {
  std::vector<ShapeRating> results;
  const ShapeTable *shapes = GetShapeTable();
  int num_results = ClassifySample(sample, page_pix, 0, unichar_id, &results);
  for (int r = 0; r < num_results; ++r) {
    if (shapes->GetShape(results[r].shape_id).ContainsUnichar(unichar_id)) {
      if (result != nullptr) {
        *result = results[r];
      }
      return results[r].shape_id;
    }
  }
  return -1;
}
// Returns the shape that contains unichar_id that has the best result.
// If result is not nullptr, it is set with the shape_id and rating.
// Does not need to be overridden if ClassifySample respects the keep_this
// rule.
Returns the shape that contains unichar_id that has the best result.
If result is not nullptr, it is set with the shape_id and rating.
Does not need to be overridden if ClassifySample respects the keep_this
rule.
Returns the shape that contains unichar_id that has the best result . If result is not nullptr it is set with the shape_id and rating . Does not need to be overridden if ClassifySample respects the keep_this rule .
int ShapeClassifier::BestShapeForUnichar(const TrainingSample &sample, Image page_pix,
                                         UNICHAR_ID unichar_id, ShapeRating *result) {
  std::vector<ShapeRating> results;
  const ShapeTable *shapes = GetShapeTable();
  int num_results = ClassifySample(sample, page_pix, 0, unichar_id, &results);
  for (int r = 0; r < num_results; ++r) {
    if (shapes->GetShape(results[r].shape_id).ContainsUnichar(unichar_id)) {
      if (result != nullptr) {
        *result = results[r];
      }
      return results[r].shape_id;
    }
  }
  return -1;
}
int ShapeClassifier :: BestShapeForUnichar ( const TrainingSample & sample , Image page_pix , UNICHAR_ID unichar_id , ShapeRating * result ) { std :: vector < ShapeRating > results ; const ShapeTable * shapes = GetShapeTable ( ) ; int num_results = ClassifySample ( sample , page_pix , 0 , unichar_id , & results ) ; for ( int r = 0 ; r < num_results ; ++ r ) { if ( shapes -> GetShape ( results [ r ] . shape_id ) . ContainsUnichar ( unichar_id ) ) { if ( result != nullptr ) { * result = results [ r ] ; } return results [ r ] . shape_id ; } } return -1 ; }
Returns the shape that contains unichar_id that has the best result.
Returns the shape that contains unichar_id that has the best result .