tesseract
5.0.0-alpha-619-ge9db
|
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_
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)
LanguageModelFlagsType top_choice_flags
LanguageModelDawgInfo * dawg_info
ParamsModel & getParamsModel()
bool AcceptableChoiceFound()
int length
number of characters on the path
bool language_model_ngram_on
int wordrec_display_segmentations
ParamsModel params_model_
double language_model_penalty_non_dict_word
bool correct_segmentation_explored_
double language_model_penalty_script
static const LanguageModelFlagsType kXhtConsistentFlag
int NumInconsistentSpaces() const
double language_model_penalty_spacing
double language_model_penalty_non_freq_dict_word
LanguageModelNgramInfo * GenerateNgramInfo(const char *unichar, float certainty, float denom, int curr_col, int curr_row, float outline_length, const ViterbiStateEntry *parent_vse)
DawgPositionVector very_beginning_active_dawgs_
float ComputeAdjustedPathCost(ViterbiStateEntry *vse)
void SetAcceptableChoiceFound(bool val)
#define double_VAR_H(name, val, comment)
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)
bool language_model_ngram_use_only_first_uft8_step
double language_model_ngram_small_prob
static const float kMaxAvgNgramCost
LanguageModel(const UnicityTable< FontInfo > *fontinfo_table, Dict *dict)
double language_model_ngram_rating_factor
Bundle together all the things pertaining to the best choice/state.
bool language_model_ngram_space_delimited_language
LanguageModelNgramInfo * ngram_info
int NumInconsistentCase() const
bool GetTopLowerUpperDigit(BLOB_CHOICE_LIST *curr_list, BLOB_CHOICE **first_lower, BLOB_CHOICE **first_upper, BLOB_CHOICE **first_digit) const
AssociateStats associate_stats
character widths/gaps/seams
double language_model_penalty_case
unsigned char LanguageModelFlagsType
Used for expressing various language model flags.
float ComputeAdjustment(int num_problems, float penalty)
Struct to store information maintained by various language model components.
int language_model_ngram_order
float ComputeDenom(BLOB_CHOICE_LIST *curr_list)
#define INT_VAR_H(name, val, comment)
LanguageModelDawgInfo * GenerateDawgInfo(bool word_end, int curr_col, int curr_row, const BLOB_CHOICE &b, const ViterbiStateEntry *parent_vse)
static const LanguageModelFlagsType kUpperCaseFlag
int prev_word_unichar_step_len_
bool acceptable_choice_found_
const UnicityTable< FontInfo > * fontinfo_table_
bool language_model_use_sigmoidal_certainty
double language_model_penalty_increment
float ComputeConsistencyAdjustment(const LanguageModelDawgInfo *dawg_info, const LMConsistencyInfo &consistency_info)
void GenerateTopChoiceInfo(ViterbiStateEntry *new_vse, const ViterbiStateEntry *parent_vse, LanguageModelState *lms)
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
int language_model_viterbi_list_max_num_prunable
static void ExtractFeaturesFromPath(const ViterbiStateEntry &vse, float features[])
WERD_CHOICE * ConstructWord(ViterbiStateEntry *vse, WERD_RES *word_res, DANGERR *fixpt, BlamerBundle *blamer_bundle, bool *truth_path)
double language_model_penalty_chartype
float CertaintyScore(float cert)
#define BOOL_VAR_H(name, val, comment)
int language_model_min_compound_length
int language_model_viterbi_list_max_size
static const LanguageModelFlagsType kLowerCaseFlag
double language_model_ngram_nonmatch_score
void FillConsistencyInfo(int curr_col, bool word_end, BLOB_CHOICE *b, ViterbiStateEntry *parent_vse, WERD_RES *word_res, LMConsistencyInfo *consistency_info)
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)
int SetTopParentLowerUpperDigit(LanguageModelState *parent_node) const
static const LanguageModelFlagsType kSmallestRatingFlag
void InitForWord(const WERD_CHOICE *prev_word, bool fixed_pitch, float max_char_wh_ratio, float rating_cert_scale)
static const LanguageModelFlagsType kDigitFlag
DawgPositionVector beginning_active_dawgs_
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_font
int language_model_debug_level
float ComputeNgramCost(const char *unichar, float certainty, float denom, const char *context, int *unichar_step_len, bool *found_small_prob, float *ngram_prob)
bool PrunablePath(const ViterbiStateEntry &vse)
double language_model_penalty_punc
bool AcceptablePath(const ViterbiStateEntry &vse)
int NumInconsistentChartype() const
void UpdateBestChoice(ViterbiStateEntry *vse, LMPainPoints *pain_points, WERD_RES *word_res, BestChoiceBundle *best_choice_bundle, BlamerBundle *blamer_bundle)
double language_model_ngram_scale_factor
int NumInconsistentPunc() const