22 #ifndef TESSERACT_WORDREC_LANGUAGE_MODEL_DEFS_H_ 23 #define TESSERACT_WORDREC_LANGUAGE_MODEL_DEFS_H_ 72 : context(c), context_unichar_step_len(l), pruned(p), ngram_cost(nc),
73 ngram_and_classifier_cost(ncc) {}
96 LanguageModelFlagsType tcf,
99 const char *debug_uch)
100 : cost(c), curr_b(b), parent_vse(pe), competing_vse(NULL),
101 ratings_sum(b->rating()),
102 min_certainty(b->certainty()), adapted(b->IsAdapted()), length(1),
103 outline_length(ol), consistency_info(ci), associate_stats(as),
104 top_choice_flags(tcf), dawg_info(d), ngram_info(n),
106 debug_str = (debug_uch == NULL) ? NULL :
new STRING();
115 if (debug_uch != NULL) *debug_str += *(pe->
debug_str);
117 if (debug_str != NULL && debug_uch != NULL) *debug_str += debug_uch;
126 static int Compare(
const void *e1,
const void *e2) {
131 return (ve1->
cost < ve2->
cost) ? -1 : 1;
134 if (dawg_info != NULL && consistency_info.NumInconsistentCase() == 0) {
137 return consistency_info.Consistent();
142 if (curr_b == NULL)
return false;
149 void Print(
const char *msg)
const;
195 viterbi_state_entries_prunable_length(0),
196 viterbi_state_entries_prunable_max_cost(
MAX_FLOAT32),
197 viterbi_state_entries_length(0) {}
203 void Print(
const char *msg);
217 : updated(false), best_vse(NULL) {
218 beam.reserve(matrix_dimension);
219 for (
int i = 0; i < matrix_dimension; ++i)
238 #endif // TESSERACT_WORDREC_LANGUAGE_MODEL_DEFS_H_
LMConsistencyInfo consistency_info
ViterbiStateEntry * best_vse
Best ViterbiStateEntry and BLOB_CHOICE.
LanguageModelDawgInfo(const DawgPositionVector *a, PermuterType pt)
ViterbiStateEntry * competing_vse
LanguageModelNgramInfo(const char *c, int l, bool p, float nc, float ncc)
BestChoiceBundle(int matrix_dimension)
float viterbi_state_entries_prunable_max_cost
PointerVector< LanguageModelState > beam
unsigned char LanguageModelFlagsType
Used for expressing various language model flags.
static int Compare(const void *e1, const void *e2)
bool get_isalpha(UNICHAR_ID unichar_id) const
float ngram_and_classifier_cost
-[ ln(P_classifier(path)) + scale_factor * ln(P_ngram_model(path)) ]
bool get_isdigit(UNICHAR_ID unichar_id) const
int context_unichar_step_len
bool updated
Flag to indicate whether anything was changed.
Bundle together all the things pertaining to the best choice/state.
bool HasAlnumChoice(const UNICHARSET &unicharset)
DANGERR fixpt
Places to try to fix the word suggested by ambiguity checking.
Struct to store information maintained by various language model components.
LanguageModelNgramInfo * ngram_info
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)
DawgPositionVector active_dawgs
ViterbiStateEntry_LIST viterbi_state_entries
Storage for the Viterbi state.
LanguageModelFlagsType top_choice_flags
LanguageModelDawgInfo * dawg_info
int viterbi_state_entries_prunable_length
Number and max cost of prunable paths in viterbi_state_entries.
ViterbiStateEntry * parent_vse
int viterbi_state_entries_length
Total number of entries in viterbi_state_entries.
AssociateStats associate_stats
BLOB_CHOICE * curr_b
Pointers to BLOB_CHOICE and parent ViterbiStateEntry (not owned by this).
float ngram_cost
-ln(P_ngram_model(path))