tesseract  4.00.00dev
tesseract::ViterbiStateEntry Struct Reference

#include <lm_state.h>

Inheritance diagram for tesseract::ViterbiStateEntry:
ELIST_LINK

Public Member Functions

 ViterbiStateEntry (ViterbiStateEntry *pe, BLOB_CHOICE *b, float c, float ol, const LMConsistencyInfo &ci, const AssociateStats &as, LanguageModelFlagsType tcf, LanguageModelDawgInfo *d, LanguageModelNgramInfo *n, const char *debug_uch)
 
 ~ViterbiStateEntry ()
 
bool Consistent () const
 
bool HasAlnumChoice (const UNICHARSET &unicharset)
 
void Print (const char *msg) const
 
- Public Member Functions inherited from ELIST_LINK
 ELIST_LINK ()
 
 ELIST_LINK (const ELIST_LINK &)
 
void operator= (const ELIST_LINK &)
 

Static Public Member Functions

static int Compare (const void *e1, const void *e2)
 

Public Attributes

float cost
 
BLOB_CHOICEcurr_b
 Pointers to BLOB_CHOICE and parent ViterbiStateEntry (not owned by this). More...
 
ViterbiStateEntryparent_vse
 
ViterbiStateEntrycompeting_vse
 
float ratings_sum
 
float min_certainty
 
int adapted
 
int length
 
float outline_length
 
LMConsistencyInfo consistency_info
 
AssociateStats associate_stats
 
LanguageModelFlagsType top_choice_flags
 
LanguageModelDawgInfodawg_info
 
LanguageModelNgramInfongram_info
 
bool updated
 
STRINGdebug_str
 

Detailed Description

Struct for storing the information about a path in the segmentation graph explored by Viterbi search.

Definition at line 91 of file lm_state.h.

Constructor & Destructor Documentation

◆ ViterbiStateEntry()

tesseract::ViterbiStateEntry::ViterbiStateEntry ( ViterbiStateEntry pe,
BLOB_CHOICE b,
float  c,
float  ol,
const LMConsistencyInfo ci,
const AssociateStats as,
LanguageModelFlagsType  tcf,
LanguageModelDawgInfo d,
LanguageModelNgramInfo n,
const char *  debug_uch 
)
inline

Definition at line 92 of file lm_state.h.

100  : cost(c), curr_b(b), parent_vse(pe), competing_vse(NULL),
101  ratings_sum(b->rating()),
105  updated(true) {
106  debug_str = (debug_uch == NULL) ? NULL : new STRING();
107  if (pe != NULL) {
108  ratings_sum += pe->ratings_sum;
109  if (pe->min_certainty < min_certainty) {
110  min_certainty = pe->min_certainty;
111  }
112  adapted += pe->adapted;
113  length += pe->length;
114  outline_length += pe->outline_length;
115  if (debug_uch != NULL) *debug_str += *(pe->debug_str);
116  }
117  if (debug_str != NULL && debug_uch != NULL) *debug_str += debug_uch;
118  }
bool IsAdapted() const
Definition: ratngs.h:135
LMConsistencyInfo consistency_info
Definition: lm_state.h:169
ViterbiStateEntry * competing_vse
Definition: lm_state.h:160
float rating() const
Definition: ratngs.h:79
float certainty() const
Definition: ratngs.h:82
ParamsEditor * pe
Definition: pgedit.cpp:108
Definition: strngs.h:45
LanguageModelNgramInfo * ngram_info
Definition: lm_state.h:182
LanguageModelFlagsType top_choice_flags
Definition: lm_state.h:174
LanguageModelDawgInfo * dawg_info
Definition: lm_state.h:178
ViterbiStateEntry * parent_vse
Definition: lm_state.h:157
AssociateStats associate_stats
Definition: lm_state.h:170
BLOB_CHOICE * curr_b
Pointers to BLOB_CHOICE and parent ViterbiStateEntry (not owned by this).
Definition: lm_state.h:156

◆ ~ViterbiStateEntry()

tesseract::ViterbiStateEntry::~ViterbiStateEntry ( )
inline

Definition at line 119 of file lm_state.h.

119  {
120  delete dawg_info;
121  delete ngram_info;
122  delete debug_str;
123  }
LanguageModelNgramInfo * ngram_info
Definition: lm_state.h:182
LanguageModelDawgInfo * dawg_info
Definition: lm_state.h:178

Member Function Documentation

◆ Compare()

static int tesseract::ViterbiStateEntry::Compare ( const void *  e1,
const void *  e2 
)
inlinestatic

Comparator function for sorting ViterbiStateEntry_LISTs in non-increasing order of costs.

Definition at line 126 of file lm_state.h.

126  {
127  const ViterbiStateEntry *ve1 =
128  *static_cast<const ViterbiStateEntry * const *>(e1);
129  const ViterbiStateEntry *ve2 =
130  *static_cast<const ViterbiStateEntry * const *>(e2);
131  return (ve1->cost < ve2->cost) ? -1 : 1;
132  }
ViterbiStateEntry(ViterbiStateEntry *pe, BLOB_CHOICE *b, float c, float ol, const LMConsistencyInfo &ci, const AssociateStats &as, LanguageModelFlagsType tcf, LanguageModelDawgInfo *d, LanguageModelNgramInfo *n, const char *debug_uch)
Definition: lm_state.h:92

◆ Consistent()

bool tesseract::ViterbiStateEntry::Consistent ( ) const
inline

Definition at line 133 of file lm_state.h.

133  {
134  if (dawg_info != NULL && consistency_info.NumInconsistentCase() == 0) {
135  return true;
136  }
137  return consistency_info.Consistent();
138  }
LMConsistencyInfo consistency_info
Definition: lm_state.h:169
LanguageModelDawgInfo * dawg_info
Definition: lm_state.h:178

◆ HasAlnumChoice()

bool tesseract::ViterbiStateEntry::HasAlnumChoice ( const UNICHARSET unicharset)
inline

Returns true if this VSE has an alphanumeric character as its classifier result.

Definition at line 141 of file lm_state.h.

141  {
142  if (curr_b == NULL) return false;
143  UNICHAR_ID unichar_id = curr_b->unichar_id();
144  if (unicharset.get_isalpha(unichar_id) ||
145  unicharset.get_isdigit(unichar_id))
146  return true;
147  return false;
148  }
int UNICHAR_ID
Definition: unichar.h:33
bool get_isalpha(UNICHAR_ID unichar_id) const
Definition: unicharset.h:451
bool get_isdigit(UNICHAR_ID unichar_id) const
Definition: unicharset.h:472
UNICHAR_ID unichar_id() const
Definition: ratngs.h:76
BLOB_CHOICE * curr_b
Pointers to BLOB_CHOICE and parent ViterbiStateEntry (not owned by this).
Definition: lm_state.h:156

◆ Print()

void tesseract::ViterbiStateEntry::Print ( const char *  msg) const

Definition at line 27 of file lm_state.cpp.

27  {
28  tprintf("%s ViterbiStateEntry", msg);
29  if (updated) tprintf("(NEW)");
30  if (this->debug_str != NULL) {
31  tprintf(" str=%s", this->debug_str->string());
32  }
33  tprintf(" with ratings_sum=%.4f length=%d cost=%.6f",
34  this->ratings_sum, this->length, this->cost);
35  if (this->top_choice_flags) {
36  tprintf(" top_choice_flags=0x%x", this->top_choice_flags);
37  }
38  if (!this->Consistent()) {
39  tprintf(" inconsistent=(punc %d case %d chartype %d script %d font %d)",
45  }
46  if (this->dawg_info) tprintf(" permuter=%d", this->dawg_info->permuter);
47  if (this->ngram_info) {
48  tprintf(" ngram_cl_cost=%g context=%s ngram pruned=%d",
50  this->ngram_info->context.string(),
51  this->ngram_info->pruned);
52  }
53  if (this->associate_stats.shape_cost > 0.0f) {
54  tprintf(" shape_cost=%g", this->associate_stats.shape_cost);
55  }
56  tprintf(" %s",
57  XHeightConsistencyEnumName[this->consistency_info.xht_decision]);
58 
59  tprintf("\n");
60 }
LMConsistencyInfo consistency_info
Definition: lm_state.h:169
#define tprintf(...)
Definition: tprintf.h:31
const char * string() const
Definition: strngs.cpp:198
float ngram_and_classifier_cost
-[ ln(P_classifier(path)) + scale_factor * ln(P_ngram_model(path)) ]
Definition: lm_state.h:86
XHeightConsistencyEnum xht_decision
LanguageModelNgramInfo * ngram_info
Definition: lm_state.h:182
LanguageModelFlagsType top_choice_flags
Definition: lm_state.h:174
LanguageModelDawgInfo * dawg_info
Definition: lm_state.h:178
AssociateStats associate_stats
Definition: lm_state.h:170

Member Data Documentation

◆ adapted

int tesseract::ViterbiStateEntry::adapted

Definition at line 166 of file lm_state.h.

◆ associate_stats

AssociateStats tesseract::ViterbiStateEntry::associate_stats

Definition at line 170 of file lm_state.h.

◆ competing_vse

ViterbiStateEntry* tesseract::ViterbiStateEntry::competing_vse

Pointer to a case-competing ViterbiStateEntry in the same list that represents a path ending in the same letter of the opposite case.

Definition at line 160 of file lm_state.h.

◆ consistency_info

LMConsistencyInfo tesseract::ViterbiStateEntry::consistency_info

Definition at line 169 of file lm_state.h.

◆ cost

float tesseract::ViterbiStateEntry::cost

The cost is an adjusted ratings sum, that is adjusted by all the language model components that use Viterbi search.

Definition at line 153 of file lm_state.h.

◆ curr_b

BLOB_CHOICE* tesseract::ViterbiStateEntry::curr_b

Pointers to BLOB_CHOICE and parent ViterbiStateEntry (not owned by this).

Definition at line 156 of file lm_state.h.

◆ dawg_info

LanguageModelDawgInfo* tesseract::ViterbiStateEntry::dawg_info

Extra information maintained by Dawg language model component (owned by ViterbiStateEntry).

Definition at line 178 of file lm_state.h.

◆ debug_str

STRING* tesseract::ViterbiStateEntry::debug_str

UTF8 string representing the path corresponding to this vse. Populated only in when language_model_debug_level > 0.

Definition at line 187 of file lm_state.h.

◆ length

int tesseract::ViterbiStateEntry::length

Definition at line 167 of file lm_state.h.

◆ min_certainty

float tesseract::ViterbiStateEntry::min_certainty

Definition at line 165 of file lm_state.h.

◆ ngram_info

LanguageModelNgramInfo* tesseract::ViterbiStateEntry::ngram_info

Extra information maintained by Ngram language model component (owned by ViterbiStateEntry).

Definition at line 182 of file lm_state.h.

◆ outline_length

float tesseract::ViterbiStateEntry::outline_length

Definition at line 168 of file lm_state.h.

◆ parent_vse

ViterbiStateEntry* tesseract::ViterbiStateEntry::parent_vse

Definition at line 157 of file lm_state.h.

◆ ratings_sum

float tesseract::ViterbiStateEntry::ratings_sum

Various information about the characters on the path represented by this ViterbiStateEntry.

Definition at line 164 of file lm_state.h.

◆ top_choice_flags

LanguageModelFlagsType tesseract::ViterbiStateEntry::top_choice_flags

Flags for marking the entry as a top choice path with the smallest rating or lower/upper case letters).

Definition at line 174 of file lm_state.h.

◆ updated

bool tesseract::ViterbiStateEntry::updated

Definition at line 184 of file lm_state.h.


The documentation for this struct was generated from the following files: