tesseract  4.00.00dev
ratngs.h
Go to the documentation of this file.
1 /**********************************************************************
2  * File: ratngs.h (Formerly ratings.h)
3  * Description: Definition of the WERD_CHOICE and BLOB_CHOICE classes.
4  * Author: Ray Smith
5  * Created: Thu Apr 23 11:40:38 BST 1992
6  *
7  * (C) Copyright 1992, Hewlett-Packard Ltd.
8  ** Licensed under the Apache License, Version 2.0 (the "License");
9  ** you may not use this file except in compliance with the License.
10  ** You may obtain a copy of the License at
11  ** http://www.apache.org/licenses/LICENSE-2.0
12  ** Unless required by applicable law or agreed to in writing, software
13  ** distributed under the License is distributed on an "AS IS" BASIS,
14  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  ** See the License for the specific language governing permissions and
16  ** limitations under the License.
17  *
18  **********************************************************************/
19 
20 #ifndef RATNGS_H
21 #define RATNGS_H
22 
23 #include <assert.h>
24 
25 #include "clst.h"
26 #include "elst.h"
27 #include "fontinfo.h"
28 #include "genericvector.h"
29 #include "matrix.h"
30 #include "unichar.h"
31 #include "unicharset.h"
32 #include "werd.h"
33 
34 class MATRIX;
35 struct TBLOB;
36 struct TWERD;
37 
38 // Enum to describe the source of a BLOB_CHOICE to make it possible to determine
39 // whether a blob has been classified by inspecting the BLOB_CHOICEs.
41  BCC_STATIC_CLASSIFIER, // From the char_norm classifier.
42  BCC_ADAPTED_CLASSIFIER, // From the adaptive classifier.
43  BCC_SPECKLE_CLASSIFIER, // Backup for failed classification.
44  BCC_AMBIG, // Generated by ambiguity detection.
45  BCC_FAKE, // From some other process.
46 };
47 
48 class BLOB_CHOICE: public ELIST_LINK
49 {
50  public:
52  unichar_id_ = UNICHAR_SPACE;
53  fontinfo_id_ = -1;
54  fontinfo_id2_ = -1;
55  rating_ = 10.0;
56  certainty_ = -1.0;
57  script_id_ = -1;
58  xgap_before_ = 0;
59  xgap_after_ = 0;
60  min_xheight_ = 0.0f;
61  max_xheight_ = 0.0f;
62  yshift_ = 0.0f;
63  classifier_ = BCC_FAKE;
64  }
65  BLOB_CHOICE(UNICHAR_ID src_unichar_id, // character id
66  float src_rating, // rating
67  float src_cert, // certainty
68  int script_id, // script
69  float min_xheight, // min xheight in image pixel units
70  float max_xheight, // max xheight allowed by this char
71  float yshift, // the larger of y shift (top or bottom)
72  BlobChoiceClassifier c); // adapted match or other
73  BLOB_CHOICE(const BLOB_CHOICE &other);
75 
77  return unichar_id_;
78  }
79  float rating() const {
80  return rating_;
81  }
82  float certainty() const {
83  return certainty_;
84  }
85  inT16 fontinfo_id() const {
86  return fontinfo_id_;
87  }
88  inT16 fontinfo_id2() const {
89  return fontinfo_id2_;
90  }
92  return fonts_;
93  }
95  fonts_ = fonts;
96  int score1 = 0, score2 = 0;
97  fontinfo_id_ = -1;
98  fontinfo_id2_ = -1;
99  for (int f = 0; f < fonts_.size(); ++f) {
100  if (fonts_[f].score > score1) {
101  score2 = 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;
108  }
109  }
110  }
111  int script_id() const {
112  return script_id_;
113  }
115  return matrix_cell_;
116  }
117  inT16 xgap_before() const {
118  return xgap_before_;
119  }
120  inT16 xgap_after() const {
121  return xgap_after_;
122  }
123  float min_xheight() const {
124  return min_xheight_;
125  }
126  float max_xheight() const {
127  return max_xheight_;
128  }
129  float yshift() const {
130  return yshift_;
131  }
133  return classifier_;
134  }
135  bool IsAdapted() const {
136  return classifier_ == BCC_ADAPTED_CLASSIFIER;
137  }
138  bool IsClassified() const {
139  return classifier_ == BCC_STATIC_CLASSIFIER ||
140  classifier_ == BCC_ADAPTED_CLASSIFIER ||
141  classifier_ == BCC_SPECKLE_CLASSIFIER;
142  }
143 
144  void set_unichar_id(UNICHAR_ID newunichar_id) {
145  unichar_id_ = newunichar_id;
146  }
147  void set_rating(float newrat) {
148  rating_ = newrat;
149  }
150  void set_certainty(float newrat) {
151  certainty_ = newrat;
152  }
153  void set_script(int newscript_id) {
154  script_id_ = newscript_id;
155  }
156  void set_matrix_cell(int col, int row) {
157  matrix_cell_.col = col;
158  matrix_cell_.row = row;
159  }
160  void set_xgap_before(inT16 gap) {
161  xgap_before_ = gap;
162  }
163  void set_xgap_after(inT16 gap) {
164  xgap_after_ = gap;
165  }
167  classifier_ = classifier;
168  }
169  static BLOB_CHOICE* deep_copy(const BLOB_CHOICE* src) {
170  BLOB_CHOICE* choice = new BLOB_CHOICE;
171  *choice = *src;
172  return choice;
173  }
174  // Returns true if *this and other agree on the baseline and x-height
175  // to within some tolerance based on a given estimate of the x-height.
176  bool PosAndSizeAgree(const BLOB_CHOICE& other, float x_height,
177  bool debug) const;
178 
179  void print(const UNICHARSET *unicharset) const {
180  tprintf("r%.2f c%.2f x[%g,%g]: %d %s",
181  rating_, certainty_,
182  min_xheight_, max_xheight_, unichar_id_,
183  (unicharset == NULL) ? "" :
184  unicharset->debug_str(unichar_id_).string());
185  }
186  void print_full() const {
187  print(NULL);
188  tprintf(" script=%d, font1=%d, font2=%d, yshift=%g, classifier=%d\n",
189  script_id_, fontinfo_id_, fontinfo_id2_, yshift_, classifier_);
190  }
191  // Sort function for sorting BLOB_CHOICEs in increasing order of rating.
192  static int SortByRating(const void *p1, const void *p2) {
193  const BLOB_CHOICE *bc1 =
194  *static_cast<const BLOB_CHOICE * const *>(p1);
195  const BLOB_CHOICE *bc2 =
196  *static_cast<const BLOB_CHOICE * const *>(p2);
197  return (bc1->rating_ < bc2->rating_) ? -1 : 1;
198  }
199 
200  private:
201  UNICHAR_ID unichar_id_; // unichar id
202  // Fonts and scores. Allowed to be empty.
204  inT16 fontinfo_id_; // char font information
205  inT16 fontinfo_id2_; // 2nd choice font information
206  // Rating is the classifier distance weighted by the length of the outline
207  // in the blob. In terms of probability, classifier distance is -klog p such
208  // that the resulting distance is in the range [0, 1] and then
209  // rating = w (-k log p) where w is the weight for the length of the outline.
210  // Sums of ratings may be compared meaningfully for words of different
211  // segmentation.
212  float rating_; // size related
213  // Certainty is a number in [-20, 0] indicating the classifier certainty
214  // of the choice. In terms of probability, certainty = 20 (k log p) where
215  // k is defined as above to normalize -klog p to the range [0, 1].
216  float certainty_; // absolute
217  int script_id_;
218  // Holds the position of this choice in the ratings matrix.
219  // Used to location position in the matrix during path backtracking.
220  MATRIX_COORD matrix_cell_;
221  inT16 xgap_before_;
222  inT16 xgap_after_;
223  // X-height range (in image pixels) that this classification supports.
224  float min_xheight_;
225  float max_xheight_;
226  // yshift_ - The vertical distance (in image pixels) the character is
227  // shifted (up or down) from an acceptable y position.
228  float yshift_;
229  BlobChoiceClassifier classifier_; // What generated *this.
230 };
231 
232 // Make BLOB_CHOICE listable.
234 
235 // Return the BLOB_CHOICE in bc_list matching a given unichar_id,
236 // or NULL if there is no match.
237 BLOB_CHOICE *FindMatchingChoice(UNICHAR_ID char_id, BLOB_CHOICE_LIST *bc_list);
238 
239 // Permuter codes used in WERD_CHOICEs.
241  NO_PERM, // 0
242  PUNC_PERM, // 1
254 
256 };
257 
258 namespace tesseract {
259 // ScriptPos tells whether a character is subscript, superscript or normal.
260 enum ScriptPos {
265 };
266 
267 const char *ScriptPosToString(tesseract::ScriptPos script_pos);
268 
269 } // namespace tesseract.
270 
271 class WERD_CHOICE : public ELIST_LINK {
272  public:
273  static const float kBadRating;
274  static const char *permuter_name(uinT8 permuter);
275 
276  WERD_CHOICE(const UNICHARSET *unicharset)
277  : unicharset_(unicharset) { this->init(8); }
278  WERD_CHOICE(const UNICHARSET *unicharset, int reserved)
279  : unicharset_(unicharset) { this->init(reserved); }
280  WERD_CHOICE(const char *src_string,
281  const char *src_lengths,
282  float src_rating,
283  float src_certainty,
284  uinT8 src_permuter,
285  const UNICHARSET &unicharset)
286  : unicharset_(&unicharset) {
287  this->init(src_string, src_lengths, src_rating,
288  src_certainty, src_permuter);
289  }
290  WERD_CHOICE(const char *src_string, const UNICHARSET &unicharset);
292  : ELIST_LINK(word), unicharset_(word.unicharset_) {
293  this->init(word.length());
294  this->operator=(word);
295  }
296  ~WERD_CHOICE();
297 
298  const UNICHARSET *unicharset() const {
299  return unicharset_;
300  }
301  inline int length() const {
302  return length_;
303  }
304  float adjust_factor() const {
305  return adjust_factor_;
306  }
307  void set_adjust_factor(float factor) {
308  adjust_factor_ = factor;
309  }
310  inline const UNICHAR_ID *unichar_ids() const {
311  return unichar_ids_;
312  }
313  inline UNICHAR_ID unichar_id(int index) const {
314  assert(index < length_);
315  return unichar_ids_[index];
316  }
317  inline int state(int index) const {
318  return state_[index];
319  }
321  if (index < 0 || index >= length_)
322  return tesseract::SP_NORMAL;
323  return script_pos_[index];
324  }
325  inline float rating() const {
326  return rating_;
327  }
328  inline float certainty() const {
329  return certainty_;
330  }
331  inline float certainty(int index) const {
332  return certainties_[index];
333  }
334  inline float min_x_height() const {
335  return min_x_height_;
336  }
337  inline float max_x_height() const {
338  return max_x_height_;
339  }
340  inline void set_x_heights(float min_height, float max_height) {
341  min_x_height_ = min_height;
342  max_x_height_ = max_height;
343  }
344  inline uinT8 permuter() const {
345  return permuter_;
346  }
347  const char *permuter_name() const;
348  // Returns the BLOB_CHOICE_LIST corresponding to the given index in the word,
349  // taken from the appropriate cell in the ratings MATRIX.
350  // Borrowed pointer, so do not delete.
351  BLOB_CHOICE_LIST* blob_choices(int index, MATRIX* ratings) const;
352 
353  // Returns the MATRIX_COORD corresponding to the location in the ratings
354  // MATRIX for the given index into the word.
355  MATRIX_COORD MatrixCoord(int index) const;
356 
357  inline void set_unichar_id(UNICHAR_ID unichar_id, int index) {
358  assert(index < length_);
359  unichar_ids_[index] = unichar_id;
360  }
361  bool dangerous_ambig_found() const {
362  return dangerous_ambig_found_;
363  }
364  void set_dangerous_ambig_found_(bool value) {
365  dangerous_ambig_found_ = value;
366  }
367  inline void set_rating(float new_val) {
368  rating_ = new_val;
369  }
370  inline void set_certainty(float new_val) {
371  certainty_ = new_val;
372  }
373  inline void set_permuter(uinT8 perm) {
374  permuter_ = perm;
375  }
376  // Note: this function should only be used if all the fields
377  // are populated manually with set_* functions (rather than
378  // (copy)constructors and append_* functions).
379  inline void set_length(int len) {
380  ASSERT_HOST(reserved_ >= len);
381  length_ = len;
382  }
383 
385  inline void double_the_size() {
386  if (reserved_ > 0) {
388  reserved_, unichar_ids_);
390  reserved_, script_pos_);
392  reserved_, state_);
394  reserved_, certainties_);
395  reserved_ *= 2;
396  } else {
397  unichar_ids_ = new UNICHAR_ID[1];
398  script_pos_ = new tesseract::ScriptPos[1];
399  state_ = new int[1];
400  certainties_ = new float[1];
401  reserved_ = 1;
402  }
403  }
404 
407  inline void init(int reserved) {
408  reserved_ = reserved;
409  if (reserved > 0) {
410  unichar_ids_ = new UNICHAR_ID[reserved];
411  script_pos_ = new tesseract::ScriptPos[reserved];
412  state_ = new int[reserved];
413  certainties_ = new float[reserved];
414  } else {
415  unichar_ids_ = NULL;
416  script_pos_ = NULL;
417  state_ = NULL;
418  certainties_ = NULL;
419  }
420  length_ = 0;
421  adjust_factor_ = 1.0f;
422  rating_ = 0.0;
423  certainty_ = MAX_FLOAT32;
424  min_x_height_ = 0.0f;
425  max_x_height_ = MAX_FLOAT32;
426  permuter_ = NO_PERM;
427  unichars_in_script_order_ = false; // Tesseract is strict left-to-right.
428  dangerous_ambig_found_ = false;
429  }
430 
436  void init(const char *src_string, const char *src_lengths,
437  float src_rating, float src_certainty,
438  uinT8 src_permuter);
439 
441  inline void make_bad() {
442  length_ = 0;
443  rating_ = kBadRating;
444  certainty_ = -MAX_FLOAT32;
445  }
446 
451  UNICHAR_ID unichar_id, int blob_count,
452  float rating, float certainty) {
453  assert(reserved_ > length_);
454  length_++;
455  this->set_unichar_id(unichar_id, blob_count,
456  rating, certainty, length_-1);
457  }
458 
459  void append_unichar_id(UNICHAR_ID unichar_id, int blob_count,
460  float rating, float certainty);
461 
462  inline void set_unichar_id(UNICHAR_ID unichar_id, int blob_count,
463  float rating, float certainty, int index) {
464  assert(index < length_);
465  unichar_ids_[index] = unichar_id;
466  state_[index] = blob_count;
467  certainties_[index] = certainty;
468  script_pos_[index] = tesseract::SP_NORMAL;
469  rating_ += rating;
470  if (certainty < certainty_) {
471  certainty_ = certainty;
472  }
473  }
474  // Sets the entries for the given index from the BLOB_CHOICE, assuming
475  // unit fragment lengths, but setting the state for this index to blob_count.
476  void set_blob_choice(int index, int blob_count,
477  const BLOB_CHOICE* blob_choice);
478 
479  bool contains_unichar_id(UNICHAR_ID unichar_id) const;
480  void remove_unichar_ids(int index, int num);
481  inline void remove_last_unichar_id() { --length_; }
482  inline void remove_unichar_id(int index) {
483  this->remove_unichar_ids(index, 1);
484  }
485  bool has_rtl_unichar_id() const;
486  void reverse_and_mirror_unichar_ids();
487 
488  // Returns the half-open interval of unichar_id indices [start, end) which
489  // enclose the core portion of this word -- the part after stripping
490  // punctuation from the left and right.
491  void punct_stripped(int *start_core, int *end_core) const;
492 
493  // Returns the indices [start, end) containing the core of the word, stripped
494  // of any superscript digits on either side. (i.e., the non-footnote part
495  // of the word). There is no guarantee that the output range is non-empty.
496  void GetNonSuperscriptSpan(int *start, int *end) const;
497 
498  // Return a copy of this WERD_CHOICE with the choices [start, end).
499  // The result is useful only for checking against a dictionary.
500  WERD_CHOICE shallow_copy(int start, int end) const;
501 
502  void string_and_lengths(STRING *word_str, STRING *word_lengths_str) const;
503  const STRING debug_string() const {
504  STRING word_str;
505  for (int i = 0; i < length_; ++i) {
506  word_str += unicharset_->debug_str(unichar_ids_[i]);
507  word_str += " ";
508  }
509  return word_str;
510  }
511  // Returns true if any unichar_id in the word is a non-space-delimited char.
513  for (int i = 0; i < length_; ++i) {
514  if (!unicharset_->IsSpaceDelimited(unichar_ids_[i])) return true;
515  }
516  return false;
517  }
518  // Returns true if the word is all spaces.
519  bool IsAllSpaces() const {
520  for (int i = 0; i < length_; ++i) {
521  if (unichar_ids_[i] != UNICHAR_SPACE) return false;
522  }
523  return true;
524  }
525 
526  // Call this to override the default (strict left to right graphemes)
527  // with the fact that some engine produces a "reading order" set of
528  // Graphemes for each word.
529  bool set_unichars_in_script_order(bool in_script_order) {
530  return unichars_in_script_order_ = in_script_order;
531  }
532 
534  return unichars_in_script_order_;
535  }
536 
537  // Returns a UTF-8 string equivalent to the current choice
538  // of UNICHAR IDs.
539  const STRING &unichar_string() const {
540  this->string_and_lengths(&unichar_string_, &unichar_lengths_);
541  return unichar_string_;
542  }
543 
544  // Returns the lengths, one byte each, representing the number of bytes
545  // required in the unichar_string for each UNICHAR_ID.
546  const STRING &unichar_lengths() const {
547  this->string_and_lengths(&unichar_string_, &unichar_lengths_);
548  return unichar_lengths_;
549  }
550 
551  // Sets up the script_pos_ member using the blobs_list to get the bln
552  // bounding boxes, *this to get the unichars, and this->unicharset
553  // to get the target positions. If small_caps is true, sub/super are not
554  // considered, but dropcaps are.
555  // NOTE: blobs_list should be the chopped_word blobs. (Fully segemented.)
556  void SetScriptPositions(bool small_caps, TWERD* word);
557  // Sets the script_pos_ member from some source positions with a given length.
558  void SetScriptPositions(const tesseract::ScriptPos* positions, int length);
559  // Sets all the script_pos_ positions to the given position.
560  void SetAllScriptPositions(tesseract::ScriptPos position);
561 
562  static tesseract::ScriptPos ScriptPositionOf(bool print_debug,
563  const UNICHARSET& unicharset,
564  const TBOX& blob_box,
565  UNICHAR_ID unichar_id);
566 
567  // Returns the "dominant" script ID for the word. By "dominant", the script
568  // must account for at least half the characters. Otherwise, it returns 0.
569  // Note that for Japanese, Hiragana and Katakana are simply treated as Han.
570  int GetTopScriptID() const;
571 
572  // Fixes the state_ for a chop at the given blob_posiiton.
573  void UpdateStateForSplit(int blob_position);
574 
575  // Returns the sum of all the state elements, being the total number of blobs.
576  int TotalOfStates() const;
577 
578  void print() const { this->print(""); }
579  void print(const char *msg) const;
580  // Prints the segmentation state with an introductory message.
581  void print_state(const char *msg) const;
582 
583  // Displays the segmentation state of *this (if not the same as the last
584  // one displayed) and waits for a click in the window.
585  void DisplaySegmentation(TWERD* word);
586 
587  WERD_CHOICE& operator+= ( // concatanate
588  const WERD_CHOICE & second);// second on first
589 
590  WERD_CHOICE& operator= (const WERD_CHOICE& source);
591 
592  private:
593  const UNICHARSET *unicharset_;
594  // TODO(rays) Perhaps replace the multiple arrays with an array of structs?
595  // unichar_ids_ is an array of classifier "results" that make up a word.
596  // For each unichar_ids_[i], script_pos_[i] has the sub/super/normal position
597  // of each unichar_id.
598  // state_[i] indicates the number of blobs in WERD_RES::chopped_word that
599  // were put together to make the classification results in the ith position
600  // in unichar_ids_, and certainties_[i] is the certainty of the choice that
601  // was used in this word.
602  // == Change from before ==
603  // Previously there was fragment_lengths_ that allowed a word to be
604  // artificially composed of multiple fragment results. Since the new
605  // segmentation search doesn't do fragments, treatment of fragments has
606  // been moved to a lower level, augmenting the ratings matrix with the
607  // combined fragments, and allowing the language-model/segmentation-search
608  // to deal with only the combined unichar_ids.
609  UNICHAR_ID *unichar_ids_; // unichar ids that represent the text of the word
610  tesseract::ScriptPos* script_pos_; // Normal/Sub/Superscript of each unichar.
611  int* state_; // Number of blobs in each unichar.
612  float* certainties_; // Certainty of each unichar.
613  int reserved_; // size of the above arrays
614  int length_; // word length
615  // Factor that was used to adjust the rating.
616  float adjust_factor_;
617  // Rating is the sum of the ratings of the individual blobs in the word.
618  float rating_; // size related
619  // certainty is the min (worst) certainty of the individual blobs in the word.
620  float certainty_; // absolute
621  // xheight computed from the result, or 0 if inconsistent.
622  float min_x_height_;
623  float max_x_height_;
624  uinT8 permuter_; // permuter code
625 
626  // Normally, the ratings_ matrix represents the recognition results in order
627  // from left-to-right. However, some engines (say Cube) may return
628  // recognition results in the order of the script's major reading direction
629  // (for Arabic, that is right-to-left).
630  bool unichars_in_script_order_;
631  // True if NoDangerousAmbig found an ambiguity.
632  bool dangerous_ambig_found_;
633 
634  // The following variables are populated and passed by reference any
635  // time unichar_string() or unichar_lengths() are called.
636  mutable STRING unichar_string_;
637  mutable STRING unichar_lengths_;
638 };
639 
640 // Make WERD_CHOICE listable.
642 typedef GenericVector<BLOB_CHOICE_LIST *> BLOB_CHOICE_LIST_VECTOR;
643 
644 // Utilities for comparing WERD_CHOICEs
645 
647  const WERD_CHOICE &word2);
648 
649 // Utilities for debug printing.
650 void print_ratings_list(
651  const char *msg, // intro message
652  BLOB_CHOICE_LIST *ratings, // list of results
653  const UNICHARSET &current_unicharset // unicharset that can be used
654  // for id-to-unichar conversion
655  );
656 
657 #endif
bool set_unichars_in_script_order(bool in_script_order)
Definition: ratngs.h:529
float yshift() const
Definition: ratngs.h:129
void set_certainty(float new_val)
Definition: ratngs.h:370
bool ContainsAnyNonSpaceDelimited() const
Definition: ratngs.h:512
bool IsAdapted() const
Definition: ratngs.h:135
const GenericVector< tesseract::ScoredFont > & fonts() const
Definition: ratngs.h:91
UNICHAR_ID unichar_id(int index) const
Definition: ratngs.h:313
void print() const
Definition: ratngs.h:578
float max_x_height() const
Definition: ratngs.h:337
void set_unichar_id(UNICHAR_ID unichar_id, int blob_count, float rating, float certainty, int index)
Definition: ratngs.h:462
float min_x_height() const
Definition: ratngs.h:334
int UNICHAR_ID
Definition: unichar.h:33
void set_length(int len)
Definition: ratngs.h:379
inT16 fontinfo_id2() const
Definition: ratngs.h:88
const MATRIX_COORD & matrix_cell()
Definition: ratngs.h:114
int length() const
Definition: ratngs.h:301
const STRING & unichar_lengths() const
Definition: ratngs.h:546
#define ELISTIZEH(CLASSNAME)
Definition: elst.h:948
BLOB_CHOICE * FindMatchingChoice(UNICHAR_ID char_id, BLOB_CHOICE_LIST *bc_list)
Definition: ratngs.cpp:160
bool IsAllSpaces() const
Definition: ratngs.h:519
static int SortByRating(const void *p1, const void *p2)
Definition: ratngs.h:192
WERD_CHOICE(const char *src_string, const char *src_lengths, float src_rating, float src_certainty, uinT8 src_permuter, const UNICHARSET &unicharset)
Definition: ratngs.h:280
void set_x_heights(float min_height, float max_height)
Definition: ratngs.h:340
float rating() const
Definition: ratngs.h:79
const STRING debug_string() const
Definition: ratngs.h:503
#define tprintf(...)
Definition: tprintf.h:31
inT16 xgap_after() const
Definition: ratngs.h:120
BLOB_CHOICE()
Definition: ratngs.h:51
const char * string() const
Definition: strngs.cpp:198
bool EqualIgnoringCaseAndTerminalPunct(const WERD_CHOICE &word1, const WERD_CHOICE &word2)
Definition: ratngs.cpp:791
void set_matrix_cell(int col, int row)
Definition: ratngs.h:156
tesseract::ScriptPos BlobPosition(int index) const
Definition: ratngs.h:320
void set_fonts(const GenericVector< tesseract::ScoredFont > &fonts)
Definition: ratngs.h:94
int size() const
Definition: genericvector.h:72
float certainty() const
Definition: ratngs.h:82
static T * double_the_size_memcpy(int current_size, T *data)
int16_t inT16
Definition: host.h:36
WERD_CHOICE(const WERD_CHOICE &word)
Definition: ratngs.h:291
#define ASSERT_HOST(x)
Definition: errcode.h:84
void remove_unichar_id(int index)
Definition: ratngs.h:482
Definition: blobs.h:395
uinT8 permuter() const
Definition: ratngs.h:344
bool IsClassified() const
Definition: ratngs.h:138
void remove_last_unichar_id()
Definition: ratngs.h:481
void print_full() const
Definition: ratngs.h:186
inT16 fontinfo_id() const
Definition: ratngs.h:85
static BLOB_CHOICE * deep_copy(const BLOB_CHOICE *src)
Definition: ratngs.h:169
~BLOB_CHOICE()
Definition: ratngs.h:74
WERD_CHOICE(const UNICHARSET *unicharset, int reserved)
Definition: ratngs.h:278
void set_script(int newscript_id)
Definition: ratngs.h:153
Definition: strngs.h:45
static const float kBadRating
Definition: ratngs.h:273
bool dangerous_ambig_found() const
Definition: ratngs.h:361
void set_certainty(float newrat)
Definition: ratngs.h:150
#define MAX_FLOAT32
Definition: host.h:66
WERD_CHOICE(const UNICHARSET *unicharset)
Definition: ratngs.h:276
ICOORD & operator+=(ICOORD &op1, const ICOORD &op2)
Definition: ipoints.h:86
void set_unichar_id(UNICHAR_ID newunichar_id)
Definition: ratngs.h:144
float min_xheight() const
Definition: ratngs.h:123
float certainty() const
Definition: ratngs.h:328
int script_id() const
Definition: ratngs.h:111
const char * ScriptPosToString(enum ScriptPos script_pos)
Definition: ratngs.cpp:180
const UNICHARSET * unicharset() const
Definition: ratngs.h:298
int state(int index) const
Definition: ratngs.h:317
void set_unichar_id(UNICHAR_ID unichar_id, int index)
Definition: ratngs.h:357
void init(int reserved)
Definition: ratngs.h:407
float certainty(int index) const
Definition: ratngs.h:331
const STRING & unichar_string() const
Definition: ratngs.h:539
void set_xgap_before(inT16 gap)
Definition: ratngs.h:160
Definition: rect.h:30
void set_rating(float new_val)
Definition: ratngs.h:367
void set_dangerous_ambig_found_(bool value)
Definition: ratngs.h:364
Definition: matrix.h:563
Definition: blobs.h:261
void append_unichar_id_space_allocated(UNICHAR_ID unichar_id, int blob_count, float rating, float certainty)
Definition: ratngs.h:450
float adjust_factor() const
Definition: ratngs.h:304
void make_bad()
Set the fields in this choice to be default (bad) values.
Definition: ratngs.h:441
uint8_t uinT8
Definition: host.h:35
const UNICHAR_ID * unichar_ids() const
Definition: ratngs.h:310
inT16 xgap_before() const
Definition: ratngs.h:117
bool PosAndSizeAgree(const BLOB_CHOICE &other, float x_height, bool debug) const
Definition: ratngs.cpp:132
void print_ratings_list(const char *msg, BLOB_CHOICE_LIST *ratings, const UNICHARSET &current_unicharset)
Definition: ratngs.cpp:819
UNICHAR_ID unichar_id() const
Definition: ratngs.h:76
void double_the_size()
Make more space in unichar_id_ and fragment_lengths_ arrays.
Definition: ratngs.h:385
void set_xgap_after(inT16 gap)
Definition: ratngs.h:163
void operator=(const ELIST_LINK &)
Definition: elst.h:101
void set_rating(float newrat)
Definition: ratngs.h:147
BlobChoiceClassifier
Definition: ratngs.h:40
void set_classifier(BlobChoiceClassifier classifier)
Definition: ratngs.h:166
bool unichars_in_script_order() const
Definition: ratngs.h:533
float max_xheight() const
Definition: ratngs.h:126
void set_permuter(uinT8 perm)
Definition: ratngs.h:373
PermuterType
Definition: ratngs.h:240
BlobChoiceClassifier classifier() const
Definition: ratngs.h:132
STRING debug_str(UNICHAR_ID id) const
Definition: unicharset.cpp:318
void print(const UNICHARSET *unicharset) const
Definition: ratngs.h:179
float rating() const
Definition: ratngs.h:325
void set_adjust_factor(float factor)
Definition: ratngs.h:307