|
tesseract 3.04.01
|
#include <lm_state.h>
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 |
Static Public Member Functions | |
| static int | Compare (const void *e1, const void *e2) |
Public Attributes | |
| float | cost |
| BLOB_CHOICE * | curr_b |
| Pointers to BLOB_CHOICE and parent ViterbiStateEntry (not owned by this). | |
| ViterbiStateEntry * | parent_vse |
| ViterbiStateEntry * | competing_vse |
| float | ratings_sum |
| float | min_certainty |
| int | adapted |
| int | length |
| float | outline_length |
| LMConsistencyInfo | consistency_info |
| AssociateStats | associate_stats |
| LanguageModelFlagsType | top_choice_flags |
| LanguageModelDawgInfo * | dawg_info |
| LanguageModelNgramInfo * | ngram_info |
| bool | updated |
| STRING * | debug_str |
Struct for storing the information about a path in the segmentation graph explored by Viterbi search.
Definition at line 95 of file lm_state.h.
| 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 96 of file lm_state.h.
: cost(c), curr_b(b), parent_vse(pe), competing_vse(NULL), ratings_sum(b->rating()), min_certainty(b->certainty()), adapted(b->IsAdapted()), length(1), outline_length(ol), consistency_info(ci), associate_stats(as), top_choice_flags(tcf), dawg_info(d), ngram_info(n), updated(true) { debug_str = (debug_uch == NULL) ? NULL : new STRING(); if (pe != NULL) { ratings_sum += pe->ratings_sum; if (pe->min_certainty < min_certainty) { min_certainty = pe->min_certainty; } adapted += pe->adapted; length += pe->length; outline_length += pe->outline_length; if (debug_uch != NULL) *debug_str += *(pe->debug_str); } if (debug_str != NULL && debug_uch != NULL) *debug_str += debug_uch; }
| tesseract::ViterbiStateEntry::~ViterbiStateEntry | ( | ) | [inline] |
Definition at line 123 of file lm_state.h.
{
delete dawg_info;
delete ngram_info;
delete debug_str;
}
| static int tesseract::ViterbiStateEntry::Compare | ( | const void * | e1, |
| const void * | e2 | ||
| ) | [inline, static] |
Comparator function for sorting ViterbiStateEntry_LISTs in non-increasing order of costs.
Definition at line 130 of file lm_state.h.
{
const ViterbiStateEntry *ve1 =
*reinterpret_cast<const ViterbiStateEntry * const *>(e1);
const ViterbiStateEntry *ve2 =
*reinterpret_cast<const ViterbiStateEntry * const *>(e2);
return (ve1->cost < ve2->cost) ? -1 : 1;
}
| bool tesseract::ViterbiStateEntry::Consistent | ( | ) | const [inline] |
Definition at line 137 of file lm_state.h.
{
if (dawg_info != NULL && consistency_info.NumInconsistentCase() == 0) {
return true;
}
return consistency_info.Consistent();
}
| bool tesseract::ViterbiStateEntry::HasAlnumChoice | ( | const UNICHARSET & | unicharset | ) | [inline] |
Returns true if this VSE has an alphanumeric character as its classifier result.
Definition at line 145 of file lm_state.h.
{
if (curr_b == NULL) return false;
UNICHAR_ID unichar_id = curr_b->unichar_id();
if (unicharset.get_isalpha(unichar_id) ||
unicharset.get_isdigit(unichar_id))
return true;
return false;
}
| void tesseract::ViterbiStateEntry::Print | ( | const char * | msg | ) | const |
Definition at line 27 of file lm_state.cpp.
{
tprintf("%s ViterbiStateEntry", msg);
if (updated) tprintf("(NEW)");
if (this->debug_str != NULL) {
tprintf(" str=%s", this->debug_str->string());
}
tprintf(" with ratings_sum=%.4f length=%d cost=%.6f",
this->ratings_sum, this->length, this->cost);
if (this->top_choice_flags) {
tprintf(" top_choice_flags=0x%x", this->top_choice_flags);
}
if (!this->Consistent()) {
tprintf(" inconsistent=(punc %d case %d chartype %d script %d font %d)",
this->consistency_info.NumInconsistentPunc(),
this->consistency_info.NumInconsistentCase(),
this->consistency_info.NumInconsistentChartype(),
this->consistency_info.inconsistent_script,
this->consistency_info.inconsistent_font);
}
if (this->dawg_info) tprintf(" permuter=%d", this->dawg_info->permuter);
if (this->ngram_info) {
tprintf(" ngram_cl_cost=%g context=%s ngram pruned=%d",
this->ngram_info->ngram_and_classifier_cost,
this->ngram_info->context.string(),
this->ngram_info->pruned);
}
if (this->associate_stats.shape_cost > 0.0f) {
tprintf(" shape_cost=%g", this->associate_stats.shape_cost);
}
tprintf(" %s",
XHeightConsistencyEnumName[this->consistency_info.xht_decision]);
tprintf("\n");
}
Definition at line 170 of file lm_state.h.
Definition at line 174 of file lm_state.h.
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 164 of file lm_state.h.
Definition at line 173 of file lm_state.h.
The cost is an adjusted ratings sum, that is adjusted by all the language model components that use Viterbi search.
Definition at line 157 of file lm_state.h.
Pointers to BLOB_CHOICE and parent ViterbiStateEntry (not owned by this).
Definition at line 160 of file lm_state.h.
Extra information maintained by Dawg language model component (owned by ViterbiStateEntry).
Definition at line 182 of file lm_state.h.
UTF8 string representing the path corresponding to this vse. Populated only in when language_model_debug_level > 0.
Definition at line 191 of file lm_state.h.
Definition at line 171 of file lm_state.h.
Definition at line 169 of file lm_state.h.
Extra information maintained by Ngram language model component (owned by ViterbiStateEntry).
Definition at line 186 of file lm_state.h.
Definition at line 172 of file lm_state.h.
Definition at line 161 of file lm_state.h.
Various information about the characters on the path represented by this ViterbiStateEntry.
Definition at line 168 of file lm_state.h.
Flags for marking the entry as a top choice path with the smallest rating or lower/upper case letters).
Definition at line 178 of file lm_state.h.
Definition at line 188 of file lm_state.h.