97 int score1 = 0, score2 = 0;
100 for (
int f = 0; f < fonts_.
size(); ++f) {
101 if (fonts_[f].score > score1) {
103 fontinfo_id2_ = fontinfo_id_;
104 score1 = fonts_[f].score;
105 fontinfo_id_ = fonts_[f].fontinfo_id;
106 }
else if (fonts_[f].score > score2) {
107 score2 = fonts_[f].score;
108 fontinfo_id2_ = fonts_[f].fontinfo_id;
146 unichar_id_ = newunichar_id;
155 script_id_ = newscript_id;
158 matrix_cell_.
col = col;
159 matrix_cell_.
row = row;
181 tprintf(
"r%.2f c%.2f x[%g,%g]: %d %s",
183 min_xheight_, max_xheight_, unichar_id_,
184 (unicharset ==
nullptr) ?
"" :
189 tprintf(
" script=%d, font1=%d, font2=%d, yshift=%g, classifier=%d\n",
190 script_id_, fontinfo_id_, fontinfo_id2_, yshift_, classifier_);
196 return (bc1->rating_ < bc2->rating_) ? -1 : 1;
206 int16_t fontinfo_id_;
207 int16_t fontinfo_id2_;
223 int16_t xgap_before_;
283 const char *src_lengths,
286 uint8_t src_permuter,
289 this->
init(src_string, src_lengths, src_rating,
290 src_certainty, src_permuter);
294 :
ELIST_LINK(word), unicharset_(word.unicharset_) {
307 return adjust_factor_;
310 adjust_factor_ = factor;
316 assert(index < length_);
317 return unichar_ids_[index];
320 return state_[index];
323 if (index < 0 || index >= length_)
325 return script_pos_[index];
334 return certainties_[index];
337 return min_x_height_;
340 return max_x_height_;
343 min_x_height_ = min_height;
344 max_x_height_ = max_height;
360 assert(index < length_);
364 return dangerous_ambig_found_;
367 dangerous_ambig_found_ = value;
373 certainty_ = new_val;
390 reserved_, unichar_ids_);
392 reserved_, script_pos_);
396 reserved_, certainties_);
402 certainties_ =
new float[1];
409 inline void init(
int reserved) {
410 reserved_ = reserved;
414 state_ =
new int[reserved];
415 certainties_ =
new float[reserved];
417 unichar_ids_ =
nullptr;
418 script_pos_ =
nullptr;
420 certainties_ =
nullptr;
423 adjust_factor_ = 1.0f;
425 certainty_ = FLT_MAX;
426 min_x_height_ = 0.0f;
427 max_x_height_ = FLT_MAX;
429 unichars_in_script_order_ =
false;
430 dangerous_ambig_found_ =
false;
438 void init(
const char *src_string,
const char *src_lengths,
439 float src_rating,
float src_certainty,
440 uint8_t src_permuter);
446 certainty_ = -FLT_MAX;
455 assert(reserved_ > length_);
466 assert(index < length_);
468 state_[index] = blob_count;
507 for (
int i = 0; i < length_; ++i) {
508 word_str += unicharset_->
debug_str(unichar_ids_[i]);
515 for (
int i = 0; i < length_; ++i) {
522 for (
int i = 0; i < length_; ++i) {
532 return unichars_in_script_order_ = in_script_order;
536 return unichars_in_script_order_;
543 return unichar_string_;
550 return unichar_lengths_;
566 const TBOX& blob_box,
581 void print(
const char *msg)
const;
618 float adjust_factor_;
632 bool unichars_in_script_order_;
634 bool dangerous_ambig_found_;
638 mutable STRING unichar_string_;
639 mutable STRING unichar_lengths_;
654 BLOB_CHOICE_LIST *ratings,
void set_unichar_id(UNICHAR_ID unichar_id, int index)
static const float kBadRating
void remove_unichar_ids(int index, int num)
void remove_unichar_id(int index)
#define ELISTIZEH(CLASSNAME)
bool IsSpaceDelimited(UNICHAR_ID unichar_id) const
static int SortByRating(const void *p1, const void *p2)
MATRIX_COORD MatrixCoord(int index) const
void set_classifier(BlobChoiceClassifier classifier)
void SetAllScriptPositions(tesseract::ScriptPos position)
void append_unichar_id_space_allocated(UNICHAR_ID unichar_id, int blob_count, float rating, float certainty)
const char * string() const
BLOB_CHOICE * FindMatchingChoice(UNICHAR_ID char_id, BLOB_CHOICE_LIST *bc_list)
void set_fonts(const GenericVector< tesseract::ScoredFont > &fonts)
int state(int index) const
void set_matrix_cell(int col, int row)
const UNICHARSET * unicharset() const
WERD_CHOICE(const UNICHARSET *unicharset, int reserved)
static T * double_the_size_memcpy(int current_size, T *data)
float certainty(int index) const
void append_unichar_id(UNICHAR_ID unichar_id, int blob_count, float rating, float certainty)
WERD_CHOICE(const char *src_string, const char *src_lengths, float src_rating, float src_certainty, uint8_t src_permuter, const UNICHARSET &unicharset)
void print(const UNICHARSET *unicharset) const
void UpdateStateForSplit(int blob_position)
bool EqualIgnoringCaseAndTerminalPunct(const WERD_CHOICE &word1, const WERD_CHOICE &word2)
void make_bad()
Set the fields in this choice to be default (bad) values.
void set_xgap_after(int16_t gap)
bool ContainsAnyNonSpaceDelimited() const
WERD_CHOICE shallow_copy(int start, int end) const
int16_t fontinfo_id() const
static BLOB_CHOICE * deep_copy(const BLOB_CHOICE *src)
bool dangerous_ambig_found() const
float max_x_height() const
void set_script(int newscript_id)
void reverse_and_mirror_unichar_ids()
const STRING & unichar_lengths() const
void set_certainty(float newrat)
void print_state(const char *msg) const
void GetNonSuperscriptSpan(int *start, int *end) const
bool PosAndSizeAgree(const BLOB_CHOICE &other, float x_height, bool debug) const
WERD_CHOICE(const WERD_CHOICE &word)
void set_rating(float newrat)
BlobChoiceClassifier classifier() const
WERD_CHOICE(const UNICHARSET *unicharset)
int16_t fontinfo_id2() const
void set_unichar_id(UNICHAR_ID newunichar_id)
void set_blob_choice(int index, int blob_count, const BLOB_CHOICE *blob_choice)
float min_xheight() const
void DisplaySegmentation(TWERD *word)
STRING debug_str(UNICHAR_ID id) const
bool has_rtl_unichar_id() const
void punct_stripped(int *start_core, int *end_core) const
const GenericVector< tesseract::ScoredFont > & fonts() const
bool contains_unichar_id(UNICHAR_ID unichar_id) const
UNICHAR_ID unichar_id(int index) const
float max_xheight() const
DLLSYM void tprintf(const char *format,...)
float adjust_factor() const
int GetTopScriptID() const
const MATRIX_COORD & matrix_cell()
void set_unichar_id(UNICHAR_ID unichar_id, int blob_count, float rating, float certainty, int index)
const UNICHAR_ID * unichar_ids() const
float min_x_height() const
const char * permuter_name() const
void string_and_lengths(STRING *word_str, STRING *word_lengths_str) const
bool IsClassified() const
void remove_last_unichar_id()
void double_the_size()
Make more space in unichar_id_ and fragment_lengths_ arrays.
int16_t xgap_before() const
const STRING debug_string() const
bool unichars_in_script_order() const
void set_x_heights(float min_height, float max_height)
void print_ratings_list(const char *msg, BLOB_CHOICE_LIST *ratings, const UNICHARSET ¤t_unicharset)
const char * ScriptPosToString(enum ScriptPos script_pos)
const STRING & unichar_string() const
void set_dangerous_ambig_found_(bool value)
tesseract::ScriptPos BlobPosition(int index) const
void SetScriptPositions(bool small_caps, TWERD *word, int debug=0)
int16_t xgap_after() const
void set_xgap_before(int16_t gap)
WERD_CHOICE & operator=(const WERD_CHOICE &source)
void set_adjust_factor(float factor)
static tesseract::ScriptPos ScriptPositionOf(bool print_debug, const UNICHARSET &unicharset, const TBOX &blob_box, UNICHAR_ID unichar_id)
bool set_unichars_in_script_order(bool in_script_order)
UNICHAR_ID unichar_id() const
void set_certainty(float new_val)
BLOB_CHOICE_LIST * blob_choices(int index, MATRIX *ratings) const
WERD_CHOICE & operator+=(const WERD_CHOICE &second)
int TotalOfStates() const
void set_rating(float new_val)
void set_permuter(uint8_t perm)