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 = *static_cast<const BLOB_CHOICE *const *>(p1);
194  const BLOB_CHOICE *bc2 = *static_cast<const BLOB_CHOICE *const *>(p2);
195  return (bc1->rating_ < bc2->rating_) ? -1 : 1;
196  }
197 
198  private:
199  UNICHAR_ID unichar_id_; // unichar id
200  // Fonts and scores. Allowed to be empty.
202  inT16 fontinfo_id_; // char font information
203  inT16 fontinfo_id2_; // 2nd choice font information
204  // Rating is the classifier distance weighted by the length of the outline
205  // in the blob. In terms of probability, classifier distance is -klog p such
206  // that the resulting distance is in the range [0, 1] and then
207  // rating = w (-k log p) where w is the weight for the length of the outline.
208  // Sums of ratings may be compared meaningfully for words of different
209  // segmentation.
210  float rating_; // size related
211  // Certainty is a number in [-20, 0] indicating the classifier certainty
212  // of the choice. In terms of probability, certainty = 20 (k log p) where
213  // k is defined as above to normalize -klog p to the range [0, 1].
214  float certainty_; // absolute
215  int script_id_;
216  // Holds the position of this choice in the ratings matrix.
217  // Used to location position in the matrix during path backtracking.
218  MATRIX_COORD matrix_cell_;
219  inT16 xgap_before_;
220  inT16 xgap_after_;
221  // X-height range (in image pixels) that this classification supports.
222  float min_xheight_;
223  float max_xheight_;
224  // yshift_ - The vertical distance (in image pixels) the character is
225  // shifted (up or down) from an acceptable y position.
226  float yshift_;
227  BlobChoiceClassifier classifier_; // What generated *this.
228 };
229 
230 // Make BLOB_CHOICE listable.
232 
233 // Return the BLOB_CHOICE in bc_list matching a given unichar_id,
234 // or NULL if there is no match.
235 BLOB_CHOICE *FindMatchingChoice(UNICHAR_ID char_id, BLOB_CHOICE_LIST *bc_list);
236 
237 // Permuter codes used in WERD_CHOICEs.
239  NO_PERM, // 0
240  PUNC_PERM, // 1
252 
254 };
255 
256 namespace tesseract {
257 // ScriptPos tells whether a character is subscript, superscript or normal.
258 enum ScriptPos {
263 };
264 
265 const char *ScriptPosToString(tesseract::ScriptPos script_pos);
266 
267 } // namespace tesseract.
268 
269 class WERD_CHOICE : public ELIST_LINK {
270  public:
271  static const float kBadRating;
272  static const char *permuter_name(uinT8 permuter);
273 
274  WERD_CHOICE(const UNICHARSET *unicharset)
275  : unicharset_(unicharset) { this->init(8); }
276  WERD_CHOICE(const UNICHARSET *unicharset, int reserved)
277  : unicharset_(unicharset) { this->init(reserved); }
278  WERD_CHOICE(const char *src_string,
279  const char *src_lengths,
280  float src_rating,
281  float src_certainty,
282  uinT8 src_permuter,
283  const UNICHARSET &unicharset)
284  : unicharset_(&unicharset) {
285  this->init(src_string, src_lengths, src_rating,
286  src_certainty, src_permuter);
287  }
288  WERD_CHOICE(const char *src_string, const UNICHARSET &unicharset);
290  : ELIST_LINK(word), unicharset_(word.unicharset_) {
291  this->init(word.length());
292  this->operator=(word);
293  }
294  ~WERD_CHOICE();
295 
296  const UNICHARSET *unicharset() const {
297  return unicharset_;
298  }
299  inline int length() const {
300  return length_;
301  }
302  float adjust_factor() const {
303  return adjust_factor_;
304  }
305  void set_adjust_factor(float factor) {
306  adjust_factor_ = factor;
307  }
308  inline const UNICHAR_ID *unichar_ids() const {
309  return unichar_ids_;
310  }
311  inline UNICHAR_ID unichar_id(int index) const {
312  assert(index < length_);
313  return unichar_ids_[index];
314  }
315  inline int state(int index) const {
316  return state_[index];
317  }
319  if (index < 0 || index >= length_)
320  return tesseract::SP_NORMAL;
321  return script_pos_[index];
322  }
323  inline float rating() const {
324  return rating_;
325  }
326  inline float certainty() const {
327  return certainty_;
328  }
329  inline float certainty(int index) const {
330  return certainties_[index];
331  }
332  inline float min_x_height() const {
333  return min_x_height_;
334  }
335  inline float max_x_height() const {
336  return max_x_height_;
337  }
338  inline void set_x_heights(float min_height, float max_height) {
339  min_x_height_ = min_height;
340  max_x_height_ = max_height;
341  }
342  inline uinT8 permuter() const {
343  return permuter_;
344  }
345  const char *permuter_name() const;
346  // Returns the BLOB_CHOICE_LIST corresponding to the given index in the word,
347  // taken from the appropriate cell in the ratings MATRIX.
348  // Borrowed pointer, so do not delete.
349  BLOB_CHOICE_LIST* blob_choices(int index, MATRIX* ratings) const;
350 
351  // Returns the MATRIX_COORD corresponding to the location in the ratings
352  // MATRIX for the given index into the word.
353  MATRIX_COORD MatrixCoord(int index) const;
354 
355  inline void set_unichar_id(UNICHAR_ID unichar_id, int index) {
356  assert(index < length_);
357  unichar_ids_[index] = unichar_id;
358  }
359  bool dangerous_ambig_found() const {
360  return dangerous_ambig_found_;
361  }
362  void set_dangerous_ambig_found_(bool value) {
363  dangerous_ambig_found_ = value;
364  }
365  inline void set_rating(float new_val) {
366  rating_ = new_val;
367  }
368  inline void set_certainty(float new_val) {
369  certainty_ = new_val;
370  }
371  inline void set_permuter(uinT8 perm) {
372  permuter_ = perm;
373  }
374  // Note: this function should only be used if all the fields
375  // are populated manually with set_* functions (rather than
376  // (copy)constructors and append_* functions).
377  inline void set_length(int len) {
378  ASSERT_HOST(reserved_ >= len);
379  length_ = len;
380  }
381 
383  inline void double_the_size() {
384  if (reserved_ > 0) {
386  reserved_, unichar_ids_);
388  reserved_, script_pos_);
390  reserved_, state_);
392  reserved_, certainties_);
393  reserved_ *= 2;
394  } else {
395  unichar_ids_ = new UNICHAR_ID[1];
396  script_pos_ = new tesseract::ScriptPos[1];
397  state_ = new int[1];
398  certainties_ = new float[1];
399  reserved_ = 1;
400  }
401  }
402 
405  inline void init(int reserved) {
406  reserved_ = reserved;
407  if (reserved > 0) {
408  unichar_ids_ = new UNICHAR_ID[reserved];
409  script_pos_ = new tesseract::ScriptPos[reserved];
410  state_ = new int[reserved];
411  certainties_ = new float[reserved];
412  } else {
413  unichar_ids_ = NULL;
414  script_pos_ = NULL;
415  state_ = NULL;
416  certainties_ = NULL;
417  }
418  length_ = 0;
419  adjust_factor_ = 1.0f;
420  rating_ = 0.0;
421  certainty_ = MAX_FLOAT32;
422  min_x_height_ = 0.0f;
423  max_x_height_ = MAX_FLOAT32;
424  permuter_ = NO_PERM;
425  unichars_in_script_order_ = false; // Tesseract is strict left-to-right.
426  dangerous_ambig_found_ = false;
427  }
428 
434  void init(const char *src_string, const char *src_lengths,
435  float src_rating, float src_certainty,
436  uinT8 src_permuter);
437 
439  inline void make_bad() {
440  length_ = 0;
441  rating_ = kBadRating;
442  certainty_ = -MAX_FLOAT32;
443  }
444 
449  UNICHAR_ID unichar_id, int blob_count,
450  float rating, float certainty) {
451  assert(reserved_ > length_);
452  length_++;
453  this->set_unichar_id(unichar_id, blob_count,
454  rating, certainty, length_-1);
455  }
456 
457  void append_unichar_id(UNICHAR_ID unichar_id, int blob_count,
458  float rating, float certainty);
459 
460  inline void set_unichar_id(UNICHAR_ID unichar_id, int blob_count,
461  float rating, float certainty, int index) {
462  assert(index < length_);
463  unichar_ids_[index] = unichar_id;
464  state_[index] = blob_count;
465  certainties_[index] = certainty;
466  script_pos_[index] = tesseract::SP_NORMAL;
467  rating_ += rating;
468  if (certainty < certainty_) {
469  certainty_ = certainty;
470  }
471  }
472  // Sets the entries for the given index from the BLOB_CHOICE, assuming
473  // unit fragment lengths, but setting the state for this index to blob_count.
474  void set_blob_choice(int index, int blob_count,
475  const BLOB_CHOICE* blob_choice);
476 
477  bool contains_unichar_id(UNICHAR_ID unichar_id) const;
478  void remove_unichar_ids(int index, int num);
479  inline void remove_last_unichar_id() { --length_; }
480  inline void remove_unichar_id(int index) {
481  this->remove_unichar_ids(index, 1);
482  }
483  bool has_rtl_unichar_id() const;
484  void reverse_and_mirror_unichar_ids();
485 
486  // Returns the half-open interval of unichar_id indices [start, end) which
487  // enclose the core portion of this word -- the part after stripping
488  // punctuation from the left and right.
489  void punct_stripped(int *start_core, int *end_core) const;
490 
491  // Returns the indices [start, end) containing the core of the word, stripped
492  // of any superscript digits on either side. (i.e., the non-footnote part
493  // of the word). There is no guarantee that the output range is non-empty.
494  void GetNonSuperscriptSpan(int *start, int *end) const;
495 
496  // Return a copy of this WERD_CHOICE with the choices [start, end).
497  // The result is useful only for checking against a dictionary.
498  WERD_CHOICE shallow_copy(int start, int end) const;
499 
500  void string_and_lengths(STRING *word_str, STRING *word_lengths_str) const;
501  const STRING debug_string() const {
502  STRING word_str;
503  for (int i = 0; i < length_; ++i) {
504  word_str += unicharset_->debug_str(unichar_ids_[i]);
505  word_str += " ";
506  }
507  return word_str;
508  }
509  // Returns true if any unichar_id in the word is a non-space-delimited char.
511  for (int i = 0; i < length_; ++i) {
512  if (!unicharset_->IsSpaceDelimited(unichar_ids_[i])) return true;
513  }
514  return false;
515  }
516  // Returns true if the word is all spaces.
517  bool IsAllSpaces() const {
518  for (int i = 0; i < length_; ++i) {
519  if (unichar_ids_[i] != UNICHAR_SPACE) return false;
520  }
521  return true;
522  }
523 
524  // Call this to override the default (strict left to right graphemes)
525  // with the fact that some engine produces a "reading order" set of
526  // Graphemes for each word.
527  bool set_unichars_in_script_order(bool in_script_order) {
528  return unichars_in_script_order_ = in_script_order;
529  }
530 
532  return unichars_in_script_order_;
533  }
534 
535  // Returns a UTF-8 string equivalent to the current choice
536  // of UNICHAR IDs.
537  const STRING &unichar_string() const {
538  this->string_and_lengths(&unichar_string_, &unichar_lengths_);
539  return unichar_string_;
540  }
541 
542  // Returns the lengths, one byte each, representing the number of bytes
543  // required in the unichar_string for each UNICHAR_ID.
544  const STRING &unichar_lengths() const {
545  this->string_and_lengths(&unichar_string_, &unichar_lengths_);
546  return unichar_lengths_;
547  }
548 
549  // Sets up the script_pos_ member using the blobs_list to get the bln
550  // bounding boxes, *this to get the unichars, and this->unicharset
551  // to get the target positions. If small_caps is true, sub/super are not
552  // considered, but dropcaps are.
553  // NOTE: blobs_list should be the chopped_word blobs. (Fully segemented.)
554  void SetScriptPositions(bool small_caps, TWERD* word);
555  // Sets the script_pos_ member from some source positions with a given length.
556  void SetScriptPositions(const tesseract::ScriptPos* positions, int length);
557  // Sets all the script_pos_ positions to the given position.
558  void SetAllScriptPositions(tesseract::ScriptPos position);
559 
560  static tesseract::ScriptPos ScriptPositionOf(bool print_debug,
561  const UNICHARSET& unicharset,
562  const TBOX& blob_box,
563  UNICHAR_ID unichar_id);
564 
565  // Returns the "dominant" script ID for the word. By "dominant", the script
566  // must account for at least half the characters. Otherwise, it returns 0.
567  // Note that for Japanese, Hiragana and Katakana are simply treated as Han.
568  int GetTopScriptID() const;
569 
570  // Fixes the state_ for a chop at the given blob_posiiton.
571  void UpdateStateForSplit(int blob_position);
572 
573  // Returns the sum of all the state elements, being the total number of blobs.
574  int TotalOfStates() const;
575 
576  void print() const { this->print(""); }
577  void print(const char *msg) const;
578  // Prints the segmentation state with an introductory message.
579  void print_state(const char *msg) const;
580 
581  // Displays the segmentation state of *this (if not the same as the last
582  // one displayed) and waits for a click in the window.
583  void DisplaySegmentation(TWERD* word);
584 
585  WERD_CHOICE& operator+= ( // concatanate
586  const WERD_CHOICE & second);// second on first
587 
588  WERD_CHOICE& operator= (const WERD_CHOICE& source);
589 
590  private:
591  const UNICHARSET *unicharset_;
592  // TODO(rays) Perhaps replace the multiple arrays with an array of structs?
593  // unichar_ids_ is an array of classifier "results" that make up a word.
594  // For each unichar_ids_[i], script_pos_[i] has the sub/super/normal position
595  // of each unichar_id.
596  // state_[i] indicates the number of blobs in WERD_RES::chopped_word that
597  // were put together to make the classification results in the ith position
598  // in unichar_ids_, and certainties_[i] is the certainty of the choice that
599  // was used in this word.
600  // == Change from before ==
601  // Previously there was fragment_lengths_ that allowed a word to be
602  // artificially composed of multiple fragment results. Since the new
603  // segmentation search doesn't do fragments, treatment of fragments has
604  // been moved to a lower level, augmenting the ratings matrix with the
605  // combined fragments, and allowing the language-model/segmentation-search
606  // to deal with only the combined unichar_ids.
607  UNICHAR_ID *unichar_ids_; // unichar ids that represent the text of the word
608  tesseract::ScriptPos* script_pos_; // Normal/Sub/Superscript of each unichar.
609  int* state_; // Number of blobs in each unichar.
610  float* certainties_; // Certainty of each unichar.
611  int reserved_; // size of the above arrays
612  int length_; // word length
613  // Factor that was used to adjust the rating.
614  float adjust_factor_;
615  // Rating is the sum of the ratings of the individual blobs in the word.
616  float rating_; // size related
617  // certainty is the min (worst) certainty of the individual blobs in the word.
618  float certainty_; // absolute
619  // xheight computed from the result, or 0 if inconsistent.
620  float min_x_height_;
621  float max_x_height_;
622  uinT8 permuter_; // permuter code
623 
624  // Normally, the ratings_ matrix represents the recognition results in order
625  // from left-to-right. However, some engines (say Cube) may return
626  // recognition results in the order of the script's major reading direction
627  // (for Arabic, that is right-to-left).
628  bool unichars_in_script_order_;
629  // True if NoDangerousAmbig found an ambiguity.
630  bool dangerous_ambig_found_;
631 
632  // The following variables are populated and passed by reference any
633  // time unichar_string() or unichar_lengths() are called.
634  mutable STRING unichar_string_;
635  mutable STRING unichar_lengths_;
636 };
637 
638 // Make WERD_CHOICE listable.
640 typedef GenericVector<BLOB_CHOICE_LIST *> BLOB_CHOICE_LIST_VECTOR;
641 
642 // Utilities for comparing WERD_CHOICEs
643 
645  const WERD_CHOICE &word2);
646 
647 // Utilities for debug printing.
648 void print_ratings_list(
649  const char *msg, // intro message
650  BLOB_CHOICE_LIST *ratings, // list of results
651  const UNICHARSET &current_unicharset // unicharset that can be used
652  // for id-to-unichar conversion
653  );
654 
655 #endif
void print(const UNICHARSET *unicharset) const
Definition: ratngs.h:179
uinT8 permuter() const
Definition: ratngs.h:342
void set_classifier(BlobChoiceClassifier classifier)
Definition: ratngs.h:166
static const float kBadRating
Definition: ratngs.h:271
int script_id() const
Definition: ratngs.h:111
void double_the_size()
Make more space in unichar_id_ and fragment_lengths_ arrays.
Definition: ratngs.h:383
const GenericVector< tesseract::ScoredFont > & fonts() const
Definition: ratngs.h:91
BLOB_CHOICE * FindMatchingChoice(UNICHAR_ID char_id, BLOB_CHOICE_LIST *bc_list)
Definition: ratngs.cpp:161
void remove_unichar_id(int index)
Definition: ratngs.h:480
BlobChoiceClassifier classifier() const
Definition: ratngs.h:132
inT16 xgap_before() const
Definition: ratngs.h:117
bool IsClassified() const
Definition: ratngs.h:138
void set_fonts(const GenericVector< tesseract::ScoredFont > &fonts)
Definition: ratngs.h:94
inT16 xgap_after() const
Definition: ratngs.h:120
bool IsAllSpaces() const
Definition: ratngs.h:517
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:278
float yshift() const
Definition: ratngs.h:129
void init(int reserved)
Definition: ratngs.h:405
void set_rating(float new_val)
Definition: ratngs.h:365
float min_xheight() const
Definition: ratngs.h:123
bool IsAdapted() const
Definition: ratngs.h:135
PermuterType
Definition: ratngs.h:238
const UNICHARSET * unicharset() const
Definition: ratngs.h:296
int16_t inT16
Definition: host.h:36
void set_unichar_id(UNICHAR_ID unichar_id, int blob_count, float rating, float certainty, int index)
Definition: ratngs.h:460
void set_unichar_id(UNICHAR_ID unichar_id, int index)
Definition: ratngs.h:355
float rating() const
Definition: ratngs.h:323
float certainty() const
Definition: ratngs.h:326
int size() const
Definition: genericvector.h:72
const STRING debug_string() const
Definition: ratngs.h:501
UNICHAR_ID unichar_id(int index) const
Definition: ratngs.h:311
static BLOB_CHOICE * deep_copy(const BLOB_CHOICE *src)
Definition: ratngs.h:169
void print() const
Definition: ratngs.h:576
void set_dangerous_ambig_found_(bool value)
Definition: ratngs.h:362
inT16 fontinfo_id2() const
Definition: ratngs.h:88
#define tprintf(...)
Definition: tprintf.h:31
float adjust_factor() const
Definition: ratngs.h:302
bool IsSpaceDelimited(UNICHAR_ID unichar_id) const
Definition: unicharset.h:651
uint8_t uinT8
Definition: host.h:35
~BLOB_CHOICE()
Definition: ratngs.h:74
float min_x_height() const
Definition: ratngs.h:332
WERD_CHOICE(const UNICHARSET *unicharset, int reserved)
Definition: ratngs.h:276
UNICHAR_ID unichar_id() const
Definition: ratngs.h:76
WERD_CHOICE(const UNICHARSET *unicharset)
Definition: ratngs.h:274
void print_ratings_list(const char *msg, BLOB_CHOICE_LIST *ratings, const UNICHARSET &current_unicharset)
Definition: ratngs.cpp:822
const char * string() const
Definition: strngs.cpp:198
Definition: blobs.h:395
BlobChoiceClassifier
Definition: ratngs.h:40
const UNICHAR_ID * unichar_ids() const
Definition: ratngs.h:308
float certainty(int index) const
Definition: ratngs.h:329
bool unichars_in_script_order() const
Definition: ratngs.h:531
const STRING & unichar_lengths() const
Definition: ratngs.h:544
void append_unichar_id_space_allocated(UNICHAR_ID unichar_id, int blob_count, float rating, float certainty)
Definition: ratngs.h:448
UNICHARSET unicharset_
Definition: strngs.h:45
void print_full() const
Definition: ratngs.h:186
void set_permuter(uinT8 perm)
Definition: ratngs.h:371
Definition: rect.h:30
Definition: matrix.h:570
Definition: blobs.h:261
void set_xgap_before(inT16 gap)
Definition: ratngs.h:160
tesseract::ScriptPos BlobPosition(int index) const
Definition: ratngs.h:318
#define ASSERT_HOST(x)
Definition: errcode.h:84
ICOORD & operator+=(ICOORD &op1, const ICOORD &op2)
Definition: ipoints.h:86
STRING debug_str(UNICHAR_ID id) const
Definition: unicharset.cpp:340
bool dangerous_ambig_found() const
Definition: ratngs.h:359
void set_xgap_after(inT16 gap)
Definition: ratngs.h:163
inT16 fontinfo_id() const
Definition: ratngs.h:85
void set_certainty(float new_val)
Definition: ratngs.h:368
bool PosAndSizeAgree(const BLOB_CHOICE &other, float x_height, bool debug) const
Definition: ratngs.cpp:133
bool ContainsAnyNonSpaceDelimited() const
Definition: ratngs.h:510
void set_unichar_id(UNICHAR_ID newunichar_id)
Definition: ratngs.h:144
float rating() const
Definition: ratngs.h:79
const MATRIX_COORD & matrix_cell()
Definition: ratngs.h:114
void set_adjust_factor(float factor)
Definition: ratngs.h:305
bool EqualIgnoringCaseAndTerminalPunct(const WERD_CHOICE &word1, const WERD_CHOICE &word2)
Definition: ratngs.cpp:794
void set_x_heights(float min_height, float max_height)
Definition: ratngs.h:338
void remove_last_unichar_id()
Definition: ratngs.h:479
int length() const
Definition: ratngs.h:299
float max_xheight() const
Definition: ratngs.h:126
void set_certainty(float newrat)
Definition: ratngs.h:150
bool set_unichars_in_script_order(bool in_script_order)
Definition: ratngs.h:527
WERD_CHOICE(const WERD_CHOICE &word)
Definition: ratngs.h:289
void make_bad()
Set the fields in this choice to be default (bad) values.
Definition: ratngs.h:439
#define MAX_FLOAT32
Definition: host.h:66
static int SortByRating(const void *p1, const void *p2)
Definition: ratngs.h:192
void set_script(int newscript_id)
Definition: ratngs.h:153
void set_length(int len)
Definition: ratngs.h:377
#define ELISTIZEH(CLASSNAME)
Definition: elst.h:948
static T * double_the_size_memcpy(int current_size, T *data)
float certainty() const
Definition: ratngs.h:82
void operator=(const ELIST_LINK &)
Definition: elst.h:101
BLOB_CHOICE()
Definition: ratngs.h:51
float max_x_height() const
Definition: ratngs.h:335
void set_matrix_cell(int col, int row)
Definition: ratngs.h:156
void set_rating(float newrat)
Definition: ratngs.h:147
int state(int index) const
Definition: ratngs.h:315
int UNICHAR_ID
Definition: unichar.h:35
const char * ScriptPosToString(enum ScriptPos script_pos)
Definition: ratngs.cpp:181
const STRING & unichar_string() const
Definition: ratngs.h:537