22 #ifndef TESSERACT_WORDREC_LANGUAGE_MODEL_DEFS_H_ 23 #define TESSERACT_WORDREC_LANGUAGE_MODEL_DEFS_H_ 99 const char *debug_uch)
115 if (debug_uch != NULL) *
debug_str += *(
pe->debug_str);
126 static int Compare(
const void *e1,
const void *e2) {
128 *reinterpret_cast<const ViterbiStateEntry * const *>(e1);
130 *reinterpret_cast<const ViterbiStateEntry * const *>(e2);
131 return (ve1->
cost < ve2->
cost) ? -1 : 1;
142 if (
curr_b == NULL)
return false;
149 void Print(
const char *msg)
const;
203 void Print(
const char *msg);
218 beam.reserve(matrix_dimension);
219 for (
int i = 0; i < matrix_dimension; ++i)
238 #endif // TESSERACT_WORDREC_LANGUAGE_MODEL_DEFS_H_ AssociateStats associate_stats
DANGERR fixpt
Places to try to fix the word suggested by ambiguity checking.
Struct to store information maintained by various language model components.
BLOB_CHOICE * curr_b
Pointers to BLOB_CHOICE and parent ViterbiStateEntry (not owned by this).
BestChoiceBundle(int matrix_dimension)
float ngram_and_classifier_cost
-[ ln(P_classifier(path)) + scale_factor * ln(P_ngram_model(path)) ]
int context_unichar_step_len
void Clear()
Clears the viterbi search state back to its initial conditions.
ViterbiStateEntry * best_vse
Best ViterbiStateEntry and BLOB_CHOICE.
PointerVector< LanguageModelState > beam
int NumInconsistentCase() const
float viterbi_state_entries_prunable_max_cost
int viterbi_state_entries_length
Total number of entries in viterbi_state_entries.
LMConsistencyInfo consistency_info
LanguageModelDawgInfo * dawg_info
bool HasAlnumChoice(const UNICHARSET &unicharset)
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)
LanguageModelFlagsType top_choice_flags
ViterbiStateEntry * parent_vse
bool updated
Flag to indicate whether anything was changed.
ViterbiStateEntry * competing_vse
void Print(const char *msg) const
float ngram_cost
-ln(P_ngram_model(path))
LanguageModelNgramInfo(const char *c, int l, bool p, float nc, float ncc)
void Print(const char *msg)
DawgPositionVector active_dawgs
int viterbi_state_entries_prunable_length
Number and max cost of prunable paths in viterbi_state_entries.
UNICHAR_ID unichar_id() const
unsigned char LanguageModelFlagsType
Used for expressing various language model flags.
static int Compare(const void *e1, const void *e2)
LanguageModelDawgInfo(const DawgPositionVector *a, PermuterType pt)
ViterbiStateEntry_LIST viterbi_state_entries
Storage for the Viterbi state.
bool get_isdigit(UNICHAR_ID unichar_id) const
Bundle together all the things pertaining to the best choice/state.
LanguageModelNgramInfo * ngram_info
bool get_isalpha(UNICHAR_ID unichar_id) const