22 #ifndef TESSERACT_WORDREC_LANGUAGE_MODEL_DEFS_H_ 23 #define TESSERACT_WORDREC_LANGUAGE_MODEL_DEFS_H_ 74 : context(c), context_unichar_step_len(l), pruned(p), ngram_cost(nc),
75 ngram_and_classifier_cost(ncc) {}
77 int context_unichar_step_len;
101 const char *debug_uch)
102 : cost(c), curr_b(b), parent_vse(pe), competing_vse(nullptr),
103 ratings_sum(b->rating()),
104 min_certainty(b->certainty()), adapted(b->IsAdapted()), length(1),
105 outline_length(ol), consistency_info(ci), associate_stats(as),
106 top_choice_flags(tcf), dawg_info(d), ngram_info(n),
108 debug_str = (debug_uch ==
nullptr) ?
nullptr :
new STRING();
117 if (debug_uch !=
nullptr) *debug_str += *(pe->
debug_str);
119 if (debug_str !=
nullptr && debug_uch !=
nullptr) *debug_str += debug_uch;
128 static int Compare(
const void *e1,
const void *e2) {
133 return (ve1->
cost < ve2->
cost) ? -1 : 1;
136 if (dawg_info !=
nullptr && consistency_info.NumInconsistentCase() == 0) {
139 return consistency_info.Consistent();
144 if (curr_b ==
nullptr)
return false;
151 void Print(
const char *msg)
const;
197 viterbi_state_entries_prunable_length(0),
198 viterbi_state_entries_prunable_max_cost(FLT_MAX),
199 viterbi_state_entries_length(0) {}
205 void Print(
const char *msg);
219 : updated(false), best_vse(nullptr) {
220 beam.reserve(matrix_dimension);
221 for (
int i = 0; i < matrix_dimension; ++i)
240 #endif // TESSERACT_WORDREC_LANGUAGE_MODEL_DEFS_H_ BestChoiceBundle(int matrix_dimension)
LanguageModelDawgInfo(const DawgPositionVector *a, PermuterType pt)
DawgPositionVector active_dawgs
Bundle together all the things pertaining to the best choice/state.
LanguageModelNgramInfo(const char *c, int l, bool p, float nc, float ncc)
float ratings_sum
sum of ratings of character on the path
bool updated
Flag to indicate whether anything was changed.
AssociateStats associate_stats
character widths/gaps/seams
float viterbi_state_entries_prunable_max_cost
ViterbiStateEntry_LIST viterbi_state_entries
Storage for the Viterbi state.
int viterbi_state_entries_length
Total number of entries in viterbi_state_entries.
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)
LanguageModelDawgInfo * dawg_info
Struct to store information maintained by various language model components.
bool get_isdigit(UNICHAR_ID unichar_id) const
static int Compare(const void *e1, const void *e2)
bool get_isalpha(UNICHAR_ID unichar_id) const
float ngram_cost
-ln(P_ngram_model(path))
int length
number of characters on the path
int viterbi_state_entries_prunable_length
Number and max cost of prunable paths in viterbi_state_entries.
LMConsistencyInfo consistency_info
path consistency info
ViterbiStateEntry * parent_vse
float min_certainty
minimum certainty on the path
ViterbiStateEntry * best_vse
Best ViterbiStateEntry and BLOB_CHOICE.
BLOB_CHOICE * curr_b
Pointers to BLOB_CHOICE and parent ViterbiStateEntry (not owned by this).
LanguageModelFlagsType top_choice_flags
float ngram_and_classifier_cost
-[ ln(P_classifier(path)) + scale_factor * ln(P_ngram_model(path)) ]
#define ELISTIZEH(CLASSNAME)
ViterbiStateEntry * competing_vse
float outline_length
length of the outline so far
PointerVector< LanguageModelState > beam
DANGERR fixpt
Places to try to fix the word suggested by ambiguity checking.
unsigned char LanguageModelFlagsType
Used for expressing various language model flags.
LanguageModelNgramInfo * ngram_info
int adapted
number of BLOB_CHOICES from adapted templates