tesseract  3.04.00
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
 
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

Definition at line 92 of file lm_state.h.

Constructor & Destructor Documentation

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 93 of file lm_state.h.

101  : cost(c), curr_b(b), parent_vse(pe), competing_vse(NULL),
102  ratings_sum(b->rating()),
106  updated(true) {
107  debug_str = (debug_uch == NULL) ? NULL : new STRING();
108  if (pe != NULL) {
109  ratings_sum += pe->ratings_sum;
110  if (pe->min_certainty < min_certainty) {
111  min_certainty = pe->min_certainty;
112  }
113  adapted += pe->adapted;
114  length += pe->length;
115  outline_length += pe->outline_length;
116  if (debug_uch != NULL) *debug_str += *(pe->debug_str);
117  }
118  if (debug_str != NULL && debug_uch != NULL) *debug_str += debug_uch;
119  }
LanguageModelDawgInfo * dawg_info
Definition: lm_state.h:179
LanguageModelFlagsType top_choice_flags
Definition: lm_state.h:175
AssociateStats associate_stats
Definition: lm_state.h:171
#define NULL
Definition: host.h:144
ViterbiStateEntry * competing_vse
Definition: lm_state.h:161
LanguageModelNgramInfo * ngram_info
Definition: lm_state.h:183
Definition: strngs.h:44
ViterbiStateEntry * parent_vse
Definition: lm_state.h:158
float rating() const
Definition: ratngs.h:79
bool IsAdapted() const
Definition: ratngs.h:135
float certainty() const
Definition: ratngs.h:82
LMConsistencyInfo consistency_info
Definition: lm_state.h:170
ParamsEditor * pe
Definition: pgedit.cpp:108
tesseract::ViterbiStateEntry::~ViterbiStateEntry ( )
inline

Definition at line 120 of file lm_state.h.

120  {
121  delete dawg_info;
122  delete ngram_info;
123  delete debug_str;
124  }
LanguageModelDawgInfo * dawg_info
Definition: lm_state.h:179
LanguageModelNgramInfo * ngram_info
Definition: lm_state.h:183

Member Function Documentation

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

Definition at line 127 of file lm_state.h.

127  {
128  const ViterbiStateEntry *ve1 =
129  *reinterpret_cast<const ViterbiStateEntry * const *>(e1);
130  const ViterbiStateEntry *ve2 =
131  *reinterpret_cast<const ViterbiStateEntry * const *>(e2);
132  return (ve1->cost < ve2->cost) ? -1 : 1;
133  }
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:93
bool tesseract::ViterbiStateEntry::Consistent ( ) const
inline

Definition at line 134 of file lm_state.h.

134  {
136  return true;
137  }
138  return consistency_info.Consistent();
139  }
LanguageModelDawgInfo * dawg_info
Definition: lm_state.h:179
#define NULL
Definition: host.h:144
LMConsistencyInfo consistency_info
Definition: lm_state.h:170
bool tesseract::ViterbiStateEntry::HasAlnumChoice ( const UNICHARSET unicharset)
inline

Definition at line 142 of file lm_state.h.

142  {
143  if (curr_b == NULL) return false;
144  UNICHAR_ID unichar_id = curr_b->unichar_id();
145  if (unicharset.get_isalpha(unichar_id) ||
146  unicharset.get_isdigit(unichar_id))
147  return true;
148  return false;
149  }
#define NULL
Definition: host.h:144
int UNICHAR_ID
Definition: unichar.h:33
bool get_isalpha(UNICHAR_ID unichar_id) const
Definition: unicharset.h:449
bool get_isdigit(UNICHAR_ID unichar_id) const
Definition: unicharset.h:470
UNICHAR_ID unichar_id() const
Definition: ratngs.h:76
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 }
#define tprintf(...)
Definition: tprintf.h:31
LanguageModelDawgInfo * dawg_info
Definition: lm_state.h:179
LanguageModelFlagsType top_choice_flags
Definition: lm_state.h:175
AssociateStats associate_stats
Definition: lm_state.h:171
#define NULL
Definition: host.h:144
const char * string() const
Definition: strngs.cpp:193
LanguageModelNgramInfo * ngram_info
Definition: lm_state.h:183
bool Consistent() const
Definition: lm_state.h:134
int NumInconsistentChartype() const
XHeightConsistencyEnum xht_decision
LMConsistencyInfo consistency_info
Definition: lm_state.h:170

Member Data Documentation

int tesseract::ViterbiStateEntry::adapted

Definition at line 167 of file lm_state.h.

AssociateStats tesseract::ViterbiStateEntry::associate_stats

Definition at line 171 of file lm_state.h.

ViterbiStateEntry* tesseract::ViterbiStateEntry::competing_vse

Definition at line 161 of file lm_state.h.

LMConsistencyInfo tesseract::ViterbiStateEntry::consistency_info

Definition at line 170 of file lm_state.h.

float tesseract::ViterbiStateEntry::cost

Definition at line 154 of file lm_state.h.

BLOB_CHOICE* tesseract::ViterbiStateEntry::curr_b

Definition at line 157 of file lm_state.h.

LanguageModelDawgInfo* tesseract::ViterbiStateEntry::dawg_info

Definition at line 179 of file lm_state.h.

STRING* tesseract::ViterbiStateEntry::debug_str

Definition at line 188 of file lm_state.h.

int tesseract::ViterbiStateEntry::length

Definition at line 168 of file lm_state.h.

float tesseract::ViterbiStateEntry::min_certainty

Definition at line 166 of file lm_state.h.

LanguageModelNgramInfo* tesseract::ViterbiStateEntry::ngram_info

Definition at line 183 of file lm_state.h.

float tesseract::ViterbiStateEntry::outline_length

Definition at line 169 of file lm_state.h.

ViterbiStateEntry* tesseract::ViterbiStateEntry::parent_vse

Definition at line 158 of file lm_state.h.

float tesseract::ViterbiStateEntry::ratings_sum

Definition at line 165 of file lm_state.h.

LanguageModelFlagsType tesseract::ViterbiStateEntry::top_choice_flags

Definition at line 175 of file lm_state.h.

bool tesseract::ViterbiStateEntry::updated

Definition at line 185 of file lm_state.h.


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