tesseract  5.0.0-alpha-619-ge9db
ratngs.h File Reference
#include <cassert>
#include <cfloat>
#include "clst.h"
#include "elst.h"
#include "fontinfo.h"
#include <tesseract/genericvector.h>
#include "matrix.h"
#include <tesseract/unichar.h>
#include "unicharset.h"
#include "werd.h"

Go to the source code of this file.

Classes

class  BLOB_CHOICE
 
class  WERD_CHOICE
 

Namespaces

 tesseract
 

Typedefs

using BLOB_CHOICE_LIST_VECTOR = GenericVector< BLOB_CHOICE_LIST * >
 

Enumerations

enum  BlobChoiceClassifier {
  BCC_STATIC_CLASSIFIER, BCC_ADAPTED_CLASSIFIER, BCC_SPECKLE_CLASSIFIER, BCC_AMBIG,
  BCC_FAKE
}
 
enum  PermuterType {
  NO_PERM, PUNC_PERM, TOP_CHOICE_PERM, LOWER_CASE_PERM,
  UPPER_CASE_PERM, NGRAM_PERM, NUMBER_PERM, USER_PATTERN_PERM,
  SYSTEM_DAWG_PERM, DOC_DAWG_PERM, USER_DAWG_PERM, FREQ_DAWG_PERM,
  COMPOUND_PERM, NUM_PERMUTER_TYPES
}
 
enum  tesseract::ScriptPos { tesseract::SP_NORMAL, tesseract::SP_SUBSCRIPT, tesseract::SP_SUPERSCRIPT, tesseract::SP_DROPCAP }
 

Functions

BLOB_CHOICEFindMatchingChoice (UNICHAR_ID char_id, BLOB_CHOICE_LIST *bc_list)
 
const char * tesseract::ScriptPosToString (enum ScriptPos script_pos)
 
bool EqualIgnoringCaseAndTerminalPunct (const WERD_CHOICE &word1, const WERD_CHOICE &word2)
 
void print_ratings_list (const char *msg, BLOB_CHOICE_LIST *ratings, const UNICHARSET &current_unicharset)
 

Typedef Documentation

◆ BLOB_CHOICE_LIST_VECTOR

using BLOB_CHOICE_LIST_VECTOR = GenericVector<BLOB_CHOICE_LIST *>

Definition at line 632 of file ratngs.h.

Enumeration Type Documentation

◆ BlobChoiceClassifier

Enumerator
BCC_STATIC_CLASSIFIER 
BCC_ADAPTED_CLASSIFIER 
BCC_SPECKLE_CLASSIFIER 
BCC_AMBIG 
BCC_FAKE 

Definition at line 41 of file ratngs.h.

42  {
43  BCC_STATIC_CLASSIFIER, // From the char_norm classifier.
44  BCC_ADAPTED_CLASSIFIER, // From the adaptive classifier.
45  BCC_SPECKLE_CLASSIFIER, // Backup for failed classification.
46  BCC_AMBIG, // Generated by ambiguity detection.
47  BCC_FAKE, // From some other process.

◆ PermuterType

Enumerator
NO_PERM 
PUNC_PERM 
TOP_CHOICE_PERM 
LOWER_CASE_PERM 
UPPER_CASE_PERM 
NGRAM_PERM 
NUMBER_PERM 
USER_PATTERN_PERM 
SYSTEM_DAWG_PERM 
DOC_DAWG_PERM 
USER_DAWG_PERM 
FREQ_DAWG_PERM 
COMPOUND_PERM 
NUM_PERMUTER_TYPES 

Definition at line 230 of file ratngs.h.

231  {
232  NO_PERM, // 0
233  PUNC_PERM, // 1
234  TOP_CHOICE_PERM, // 2
235  LOWER_CASE_PERM, // 3
236  UPPER_CASE_PERM, // 4
237  NGRAM_PERM, // 5
238  NUMBER_PERM, // 6
239  USER_PATTERN_PERM, // 7
240  SYSTEM_DAWG_PERM, // 8
241  DOC_DAWG_PERM, // 9
242  USER_DAWG_PERM, // 10
243  FREQ_DAWG_PERM, // 11
244  COMPOUND_PERM, // 12
245 

Function Documentation

◆ EqualIgnoringCaseAndTerminalPunct()

bool EqualIgnoringCaseAndTerminalPunct ( const WERD_CHOICE word1,
const WERD_CHOICE word2 
)

Definition at line 807 of file ratngs.cpp.

809  {
810  const UNICHARSET *uchset = word1.unicharset();
811  if (word2.unicharset() != uchset) return false;
812  int w1start, w1end;
813  word1.punct_stripped(&w1start, &w1end);
814  int w2start, w2end;
815  word2.punct_stripped(&w2start, &w2end);
816  if (w1end - w1start != w2end - w2start) return false;
817  for (int i = 0; i < w1end - w1start; i++) {
818  if (uchset->to_lower(word1.unichar_id(w1start + i)) !=
819  uchset->to_lower(word2.unichar_id(w2start + i))) {
820  return false;
821  }
822  }
823  return true;

◆ FindMatchingChoice()

BLOB_CHOICE* FindMatchingChoice ( UNICHAR_ID  char_id,
BLOB_CHOICE_LIST *  bc_list 
)

Definition at line 182 of file ratngs.cpp.

184  {
185  // Find the corresponding best BLOB_CHOICE.
186  BLOB_CHOICE_IT choice_it(bc_list);
187  for (choice_it.mark_cycle_pt(); !choice_it.cycled_list();
188  choice_it.forward()) {
189  BLOB_CHOICE* choice = choice_it.data();
190  if (choice->unichar_id() == char_id) {
191  return choice;
192  }
193  }
194  return nullptr;

◆ print_ratings_list()

void print_ratings_list ( const char *  msg,
BLOB_CHOICE_LIST *  ratings,
const UNICHARSET current_unicharset 
)

print_ratings_list

Send all the ratings out to the logfile.

Parameters
msgintro message
ratingslist of ratings
current_unicharsetunicharset that can be used for id-to-unichar conversion

Definition at line 835 of file ratngs.cpp.

838  {
839  if (ratings->length() == 0) {
840  tprintf("%s:<none>\n", msg);
841  return;
842  }
843  if (*msg != '\0') {
844  tprintf("%s\n", msg);
845  }
846  BLOB_CHOICE_IT c_it;
847  c_it.set_to_list(ratings);
848  for (c_it.mark_cycle_pt(); !c_it.cycled_list(); c_it.forward()) {
849  c_it.data()->print(&current_unicharset);
850  if (!c_it.at_last()) tprintf("\n");
851  }
852  tprintf("\n");
853  fflush(stdout);
NUM_PERMUTER_TYPES
Definition: ratngs.h:245
BCC_FAKE
Definition: ratngs.h:46
WERD_CHOICE::unichar_id
UNICHAR_ID unichar_id(int index) const
Definition: ratngs.h:303
SYSTEM_DAWG_PERM
Definition: ratngs.h:239
NO_PERM
Definition: ratngs.h:231
BCC_ADAPTED_CLASSIFIER
Definition: ratngs.h:43
COMPOUND_PERM
Definition: ratngs.h:243
WERD_CHOICE::unicharset
const UNICHARSET * unicharset() const
Definition: ratngs.h:288
BLOB_CHOICE::unichar_id
UNICHAR_ID unichar_id() const
Definition: ratngs.h:75
BCC_AMBIG
Definition: ratngs.h:45
UPPER_CASE_PERM
Definition: ratngs.h:235
WERD_CHOICE::punct_stripped
void punct_stripped(int *start_core, int *end_core) const
Definition: ratngs.cpp:385
UNICHARSET::to_lower
UNICHAR_ID to_lower(UNICHAR_ID unichar_id) const
Definition: unicharset.h:694
UNICHARSET
Definition: unicharset.h:145
NGRAM_PERM
Definition: ratngs.h:236
TOP_CHOICE_PERM
Definition: ratngs.h:233
USER_PATTERN_PERM
Definition: ratngs.h:238
BLOB_CHOICE
Definition: ratngs.h:49
tprintf
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:34
LOWER_CASE_PERM
Definition: ratngs.h:234
DOC_DAWG_PERM
Definition: ratngs.h:240
PUNC_PERM
Definition: ratngs.h:232
FREQ_DAWG_PERM
Definition: ratngs.h:242
NUMBER_PERM
Definition: ratngs.h:237
BCC_SPECKLE_CLASSIFIER
Definition: ratngs.h:44
USER_DAWG_PERM
Definition: ratngs.h:241
BCC_STATIC_CLASSIFIER
Definition: ratngs.h:42