96 int score1 = 0, score2 = 0;
99 for (
int f = 0; f < fonts_.
size(); ++f) {
100 if (fonts_[f].score > score1) {
102 fontinfo_id2_ = fontinfo_id_;
103 score1 = fonts_[f].score;
104 fontinfo_id_ = fonts_[f].fontinfo_id;
105 }
else if (fonts_[f].score > score2) {
106 score2 = fonts_[f].score;
107 fontinfo_id2_ = fonts_[f].fontinfo_id;
145 unichar_id_ = newunichar_id;
154 script_id_ = newscript_id;
157 matrix_cell_.
col = col;
158 matrix_cell_.
row = row;
180 tprintf(
"r%.2f c%.2f x[%g,%g]: %d %s",
182 min_xheight_, max_xheight_, unichar_id_,
183 (unicharset ==
NULL) ?
"" :
188 tprintf(
" script=%d, font1=%d, font2=%d, yshift=%g, classifier=%d\n",
189 script_id_, fontinfo_id_, fontinfo_id2_, yshift_, classifier_);
194 *
reinterpret_cast<const BLOB_CHOICE *
const *
>(p1);
196 *
reinterpret_cast<const BLOB_CHOICE *
const *
>(p2);
197 return (bc1->rating_ < bc2->rating_) ? -1 : 1;
277 : unicharset_(unicharset) { this->
init(8); }
279 : unicharset_(unicharset) { this->
init(reserved); }
281 const char *src_lengths,
286 : unicharset_(&unicharset) {
287 this->
init(src_string, src_lengths, src_rating,
288 src_certainty, src_permuter);
304 return adjust_factor_;
307 adjust_factor_ = factor;
313 assert(index < length_);
314 return unichar_ids_[index];
317 return state_[index];
320 if (index < 0 || index >= length_)
322 return script_pos_[index];
331 return certainties_[index];
334 return min_x_height_;
337 return max_x_height_;
340 min_x_height_ = min_height;
341 max_x_height_ = max_height;
357 assert(index < length_);
361 return dangerous_ambig_found_;
364 dangerous_ambig_found_ = value;
370 certainty_ = new_val;
387 reserved_, unichar_ids_);
389 reserved_, script_pos_);
393 reserved_, certainties_);
399 certainties_ =
new float[1];
406 inline void init(
int reserved) {
407 reserved_ = reserved;
411 state_ =
new int[reserved];
412 certainties_ =
new float[reserved];
420 adjust_factor_ = 1.0f;
423 min_x_height_ = 0.0f;
426 unichars_in_script_order_ =
false;
427 dangerous_ambig_found_ =
false;
435 void init(
const char *src_string,
const char *src_lengths,
436 float src_rating,
float src_certainty,
452 assert(reserved_ > length_);
455 rating, certainty, length_-1);
463 assert(index < length_);
465 state_[index] = blob_count;
469 if (certainty < certainty_) {
504 for (
int i = 0; i < length_; ++i) {
505 word_str += unicharset_->
debug_str(unichar_ids_[i]);
515 return unichars_in_script_order_ = in_script_order;
519 return unichars_in_script_order_;
526 return unichar_string_;
533 return unichar_lengths_;
549 const TBOX& blob_box,
564 void print(
const char *msg)
const;
601 float adjust_factor_;
615 bool unichars_in_script_order_;
617 bool dangerous_ambig_found_;
621 mutable STRING unichar_string_;
622 mutable STRING unichar_lengths_;
637 BLOB_CHOICE_LIST *ratings,
tesseract::ScriptPos BlobPosition(int index) const
void append_unichar_id(UNICHAR_ID unichar_id, int blob_count, float rating, float certainty)
const UNICHAR_ID * unichar_ids() const
STRING debug_str(UNICHAR_ID id) const
void set_unichar_id(UNICHAR_ID unichar_id, int index)
BLOB_CHOICE_LIST * blob_choices(int index, MATRIX *ratings) const
static const float kBadRating
void remove_unichar_id(int index)
void DisplaySegmentation(TWERD *word)
void set_unichar_id(UNICHAR_ID unichar_id, int blob_count, float rating, float certainty, int index)
void SetScriptPositions(bool small_caps, TWERD *word)
static T * double_the_size_memcpy(int current_size, T *data)
void set_certainty(float new_val)
bool unichars_in_script_order() const
bool contains_unichar_id(UNICHAR_ID unichar_id) const
WERD_CHOICE & operator=(const WERD_CHOICE &source)
BlobChoiceClassifier classifier() const
static int SortByRating(const void *p1, const void *p2)
void punct_stripped(int *start_core, int *end_core) const
void print(const UNICHARSET *unicharset) const
void append_unichar_id_space_allocated(UNICHAR_ID unichar_id, int blob_count, float rating, float certainty)
const char * permuter_name() const
void set_x_heights(float min_height, float max_height)
float min_xheight() const
void set_permuter(uinT8 perm)
WERD_CHOICE & operator+=(const WERD_CHOICE &second)
void set_xgap_before(inT16 gap)
void print_ratings_list(const char *msg, BLOB_CHOICE_LIST *ratings, const UNICHARSET ¤t_unicharset)
const STRING & unichar_lengths() const
WERD_CHOICE(const UNICHARSET *unicharset)
bool has_rtl_unichar_id() const
static BLOB_CHOICE * deep_copy(const BLOB_CHOICE *src)
void UpdateStateForSplit(int blob_position)
WERD_CHOICE shallow_copy(int start, int end) const
float min_x_height() const
bool dangerous_ambig_found() const
void print_state(const char *msg) const
const STRING & unichar_string() const
int GetTopScriptID() const
const UNICHARSET * unicharset() const
void reverse_and_mirror_unichar_ids()
const char * ScriptPosToString(enum ScriptPos script_pos)
MATRIX_COORD MatrixCoord(int index) const
void double_the_size()
Make more space in unichar_id_ and fragment_lengths_ arrays.
void GetNonSuperscriptSpan(int *start, int *end) const
inT16 fontinfo_id() const
WERD_CHOICE(const UNICHARSET *unicharset, int reserved)
int state(int index) const
void set_classifier(BlobChoiceClassifier classifier)
void remove_last_unichar_id()
bool set_unichars_in_script_order(bool in_script_order)
void make_bad()
Set the fields in this choice to be default (bad) values.
static tesseract::ScriptPos ScriptPositionOf(bool print_debug, const UNICHARSET &unicharset, const TBOX &blob_box, UNICHAR_ID unichar_id)
void set_xgap_after(inT16 gap)
void set_certainty(float newrat)
WERD_CHOICE(const WERD_CHOICE &word)
const UNICHAR_ID unichar_id(int index) const
inT16 xgap_before() const
const STRING debug_string() const
void set_matrix_cell(int col, int row)
#define ELISTIZEH(CLASSNAME)
inT16 fontinfo_id2() const
void string_and_lengths(STRING *word_str, STRING *word_lengths_str) const
void set_script(int newscript_id)
float max_x_height() const
bool IsClassified() const
void set_blob_choice(int index, int blob_count, const BLOB_CHOICE *blob_choice)
WERD_CHOICE(const char *src_string, const char *src_lengths, float src_rating, float src_certainty, uinT8 src_permuter, const UNICHARSET &unicharset)
float adjust_factor() const
bool PosAndSizeAgree(const BLOB_CHOICE &other, float x_height, bool debug) const
void set_fonts(const GenericVector< tesseract::ScoredFont > &fonts)
float certainty(int index) const
void remove_unichar_ids(int index, int num)
bool EqualIgnoringCaseAndTerminalPunct(const WERD_CHOICE &word1, const WERD_CHOICE &word2)
BLOB_CHOICE * FindMatchingChoice(UNICHAR_ID char_id, BLOB_CHOICE_LIST *bc_list)
const GenericVector< tesseract::ScoredFont > & fonts() const
void set_rating(float newrat)
void SetAllScriptPositions(tesseract::ScriptPos position)
const char * string() const
int TotalOfStates() const
const MATRIX_COORD & matrix_cell()
void set_adjust_factor(float factor)
UNICHAR_ID unichar_id() const
float max_xheight() const
void set_rating(float new_val)
void set_unichar_id(UNICHAR_ID newunichar_id)
void set_dangerous_ambig_found_(bool value)