Go to the documentation of this file.
21 #ifndef TESSERACT_WORDREC_LANGUAGE_MODEL_H_
22 #define TESSERACT_WORDREC_LANGUAGE_MODEL_H_
77 bool fixed_pitch,
float max_char_wh_ratio,
78 float rating_cert_scale);
94 int curr_col,
int curr_row,
95 BLOB_CHOICE_LIST *curr_list,
118 return 1.0f / (1.0f + exp(10.0f * cert));
120 return (-1.0f / cert);
125 if (num_problems == 0)
return 0.0f;
126 if (num_problems == 1)
return penalty;
128 static_cast<float>(num_problems-1)));
138 if (dawg_info !=
nullptr) {
183 bool just_classified,
bool mixed_alnum,
186 ViterbiStateEntry_IT* vse_it,
214 int curr_col,
int curr_row,
226 const char *unichar,
float certainty,
float denom,
227 int curr_col,
int curr_row,
float outline_length,
238 const char *context,
int *unichar_step_len,
239 bool *found_small_prob,
float *ngram_prob);
281 float max_char_wh_ratio,
288 (parent_vse !=
nullptr) ? parent_vse->
length : 0,
318 "Turn on/off the use of character ngram model");
320 "Maximum order of the character ngram model");
322 "Maximum number of prunable (those for which PrunablePath() is"
323 " true) entries in each viterbi list recorded in BLOB_CHOICEs");
325 "Maximum size of viterbi lists recorded in BLOB_CHOICEs");
327 "To avoid overly small denominators use this as the floor"
328 " of the probability returned by the ngram model");
330 "Average classifier score of a non-matching unichar");
332 "Use only the first UTF8 step of the given string"
333 " when computing log probabilities");
335 "Strength of the character ngram model relative to the"
336 " character classifier ");
338 "Factor to bring log-probs into the same range as ratings"
339 " when multiplied by outline length ");
341 "Words are delimited by space");
343 "Minimum length of compound words");
346 "Penalty for words not in the frequent word dictionary");
348 "Penalty for non-dictionary words");
350 "Penalty for inconsistent punctuation");
352 "Penalty for inconsistent case");
354 "Penalty for inconsistent script");
356 "Penalty for inconsistent character type");
358 "Penalty for inconsistent font");
360 "Penalty for inconsistent spacing");
364 "Use sigmoidal score for certainty");
426 #endif // TESSERACT_WORDREC_LANGUAGE_MODEL_H_
int NumInconsistentPunc() const
int NumInconsistentCase() const
double language_model_penalty_chartype
bool AddViterbiStateEntry(LanguageModelFlagsType top_choice_flags, float denom, bool word_end, int curr_col, int curr_row, BLOB_CHOICE *b, LanguageModelState *curr_state, ViterbiStateEntry *parent_vse, LMPainPoints *pain_points, WERD_RES *word_res, BestChoiceBundle *best_choice_bundle, BlamerBundle *blamer_bundle)
double language_model_penalty_case
LanguageModelDawgInfo * dawg_info
static const LanguageModelFlagsType kXhtConsistentFlag
Bundle together all the things pertaining to the best choice/state.
int wordrec_display_segmentations
float ComputeDenom(BLOB_CHOICE_LIST *curr_list)
double language_model_ngram_small_prob
static void ExtractFeaturesFromPath(const ViterbiStateEntry &vse, float features[])
#define double_VAR_H(name, val, comment)
int language_model_viterbi_list_max_num_prunable
int length
number of characters on the path
#define INT_VAR_H(name, val, comment)
LanguageModelNgramInfo * GenerateNgramInfo(const char *unichar, float certainty, float denom, int curr_col, int curr_row, float outline_length, const ViterbiStateEntry *parent_vse)
double language_model_ngram_rating_factor
int SetTopParentLowerUpperDigit(LanguageModelState *parent_node) const
AssociateStats associate_stats
character widths/gaps/seams
int language_model_debug_level
double language_model_penalty_script
double language_model_penalty_font
double language_model_ngram_scale_factor
bool language_model_ngram_space_delimited_language
double language_model_penalty_non_dict_word
bool PrunablePath(const ViterbiStateEntry &vse)
float ComputeAdjustment(int num_problems, float penalty)
LanguageModelDawgInfo * GenerateDawgInfo(bool word_end, int curr_col, int curr_row, const BLOB_CHOICE &b, const ViterbiStateEntry *parent_vse)
bool language_model_ngram_use_only_first_uft8_step
ParamsModel & getParamsModel()
void GenerateTopChoiceInfo(ViterbiStateEntry *new_vse, const ViterbiStateEntry *parent_vse, LanguageModelState *lms)
LanguageModel(const UnicityTable< FontInfo > *fontinfo_table, Dict *dict)
static const LanguageModelFlagsType kUpperCaseFlag
int NumInconsistentSpaces() const
bool language_model_use_sigmoidal_certainty
#define BOOL_VAR_H(name, val, comment)
static void ComputeStats(int col, int row, const AssociateStats *parent_stats, int parent_path_length, bool fixed_pitch, float max_char_wh_ratio, WERD_RES *word_res, bool debug, AssociateStats *stats)
bool correct_segmentation_explored_
float ComputeAdjustedPathCost(ViterbiStateEntry *vse)
double language_model_penalty_non_freq_dict_word
double language_model_ngram_nonmatch_score
DawgPositionVector very_beginning_active_dawgs_
bool language_model_ngram_on
bool AcceptableChoiceFound()
ParamsModel params_model_
static const LanguageModelFlagsType kDigitFlag
int language_model_min_compound_length
unsigned char LanguageModelFlagsType
Used for expressing various language model flags.
void InitForWord(const WERD_CHOICE *prev_word, bool fixed_pitch, float max_char_wh_ratio, float rating_cert_scale)
static const float kMaxAvgNgramCost
const UnicityTable< FontInfo > * fontinfo_table_
LanguageModelNgramInfo * ngram_info
float ComputeConsistencyAdjustment(const LanguageModelDawgInfo *dawg_info, const LMConsistencyInfo &consistency_info)
LanguageModelFlagsType top_choice_flags
float ComputeNgramCost(const char *unichar, float certainty, float denom, const char *context, int *unichar_step_len, bool *found_small_prob, float *ngram_prob)
static const LanguageModelFlagsType kLowerCaseFlag
void UpdateBestChoice(ViterbiStateEntry *vse, LMPainPoints *pain_points, WERD_RES *word_res, BestChoiceBundle *best_choice_bundle, BlamerBundle *blamer_bundle)
void FillConsistencyInfo(int curr_col, bool word_end, BLOB_CHOICE *b, ViterbiStateEntry *parent_vse, WERD_RES *word_res, LMConsistencyInfo *consistency_info)
bool GetTopLowerUpperDigit(BLOB_CHOICE_LIST *curr_list, BLOB_CHOICE **first_lower, BLOB_CHOICE **first_upper, BLOB_CHOICE **first_digit) const
int language_model_ngram_order
Struct to store information maintained by various language model components.
WERD_CHOICE * ConstructWord(ViterbiStateEntry *vse, WERD_RES *word_res, DANGERR *fixpt, BlamerBundle *blamer_bundle, bool *truth_path)
ViterbiStateEntry * GetNextParentVSE(bool just_classified, bool mixed_alnum, const BLOB_CHOICE *bc, LanguageModelFlagsType blob_choice_flags, const UNICHARSET &unicharset, WERD_RES *word_res, ViterbiStateEntry_IT *vse_it, LanguageModelFlagsType *top_choice_flags) const
bool AcceptablePath(const ViterbiStateEntry &vse)
int NumInconsistentChartype() const
double language_model_penalty_spacing
bool acceptable_choice_found_
void ComputeAssociateStats(int col, int row, float max_char_wh_ratio, ViterbiStateEntry *parent_vse, WERD_RES *word_res, AssociateStats *associate_stats)
double language_model_penalty_increment
double language_model_penalty_punc
void SetAcceptableChoiceFound(bool val)
int prev_word_unichar_step_len_
bool UpdateState(bool just_classified, int curr_col, int curr_row, BLOB_CHOICE_LIST *curr_list, LanguageModelState *parent_node, LMPainPoints *pain_points, WERD_RES *word_res, BestChoiceBundle *best_choice_bundle, BlamerBundle *blamer_bundle)
int language_model_viterbi_list_max_size
static const LanguageModelFlagsType kSmallestRatingFlag
float CertaintyScore(float cert)
DawgPositionVector beginning_active_dawgs_