34 SegSearch(word_res, &best_choice_bundle, NULL);
54 blamer_bundle, &pain_points, &pending);
58 if (blamer_bundle != NULL &&
66 float pain_point_priority;
67 int num_futile_classifications = 0;
71 (blamer_bundle != NULL &&
74 bool found_nothing =
true;
76 while ((pp_type = pain_points.
Deque(&pain_point, &pain_point_priority)) !=
80 pain_point.
row - pain_point.
col + 1);
85 found_nothing =
false;
95 &pending, word_res, &pain_points, blamer_bundle);
98 word_res, &pain_points, best_choice_bundle,
100 if (!best_choice_bundle->
updated) ++num_futile_classifications;
103 tprintf(
"num_futile_classifications %d\n", num_futile_classifications);
106 best_choice_bundle->
updated =
false;
111 blamer_bundle != NULL &&
117 if (blamer_bundle != NULL) {
123 tprintf(
"Done with SegSearch (AcceptableChoiceFound: %d)\n",
138 InitialSegSearch(word_res, &pain_points, &pending, &best_choice_bundle, NULL);
140 tprintf(
"Ending ratings matrix%s:\n",
155 tprintf(
"Starting SegSearch on ratings matrix%s:\n",
174 if (blamer_bundle != NULL) {
189 (*pending)[0].SetColumnClassified();
191 pain_points, best_choice_bundle, blamer_bundle);
195 float rating_cert_scale,
205 for (
int col = starting_col; col < ratings->
dimension(); ++col) {
206 if (!(*pending)[col].WorkToDo())
continue;
210 if ((*pending)[col].SingleRow() >= 0) {
211 first_row = last_row = (*pending)[col].SingleRow();
214 tprintf(
"\n\nUpdateSegSearchNodes: col=%d, rows=[%d,%d], alljust=%d\n",
215 col, first_row, last_row,
216 (*pending)[col].IsRowJustClassified(
MAX_INT32));
219 for (
int row = first_row; row <= last_row; ++row) {
221 BLOB_CHOICE_LIST *current_node = ratings->
get(col, row);
223 col == 0 ? NULL : best_choice_bundle->
beam[col - 1];
224 if (current_node != NULL &&
226 col, row, current_node, parent_node,
227 pain_points, word_res,
228 best_choice_bundle, blamer_bundle) &&
232 (*pending)[row + 1].RevisitWholeColumn();
234 tprintf(
"Added child col=%d to pending\n", row + 1);
239 if (best_choice_bundle->
best_vse != NULL) {
243 best_choice_bundle->
best_vse, word_res);
246 best_choice_bundle->
best_vse, word_res);
252 for (
int col = 0; col < pending->
size(); ++col) {
253 (*pending)[col].Clear();
255 vse_it(&best_choice_bundle->
beam[col]->viterbi_state_entries);
256 for (vse_it.mark_cycle_pt(); !vse_it.cycled_list(); vse_it.forward()) {
257 vse_it.data()->updated =
false;
263 float pain_point_priority,
264 const MATRIX_COORD &pain_point,
const char* pain_point_type,
268 tprintf(
"Classifying pain point %s priority=%.4f, col=%d, row=%d\n",
269 pain_point_type, pain_point_priority,
270 pain_point.
col, pain_point.
row);
275 if (!pain_point.
Valid(*ratings)) {
280 pain_point.
col, pain_point.
row,
284 BLOB_CHOICE_LIST *lst = ratings->
get(pain_point.
col, pain_point.
row);
286 ratings->
put(pain_point.
col, pain_point.
row, classified);
292 BLOB_CHOICE_IT it(lst);
293 it.add_list_before(classified);
300 ratings->
get(pain_point.
col, pain_point.
row),
307 if (classified != NULL && !classified->empty()) {
308 if (pain_point.
col > 0) {
319 (*pending)[pain_point.
col].SetBlobClassified(pain_point.
row);
330 for (
int col = 0; col < best_choice_bundle->
beam.size(); ++col) {
331 best_choice_bundle->
beam[col]->Clear();
335 best_choice_bundle->
best_vse = NULL;
337 (*pending)[0].SetColumnClassified();
338 for (
int i = 1; i < pending->
size(); ++i)
339 (*pending)[i].Clear();
346 pain_points->
Clear();
352 blamer_debug, pp_cb);
bool updated
Flag to indicate whether anything was changed.
bool wordrec_enable_assoc
Bundle together all the things pertaining to the best choice/state.
virtual BLOB_CHOICE_LIST * classify_piece(const GenericVector< SEAM *> &seams, inT16 start, inT16 end, const char *description, TWERD *word, BlamerBundle *blamer_bundle)
void IncreaseBandSize(int bandwidth)
void SetupCorrectSegmentation(const TWERD *word, bool debug)
_ConstTessMemberResultCallback_0_0< false, R, T1 >::base * NewPermanentTessCallback(const T1 *obj, R(T2::*member)() const)
bool AcceptableChoiceFound()
Struct to store information maintained by various language model components.
bool GenerateForBlamer(double max_char_wh_ratio, WERD_RES *word_res, int col, int row)
void FinishSegSearch(const WERD_CHOICE *best_choice, bool debug, STRING *debug_str)
static void PrintSeams(const char *label, const GenericVector< SEAM *> &seams)
void WordSearch(WERD_RES *word_res)
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)
const UNICHARSET & getUnicharset() const
PointerVector< LanguageModelState > beam
bool GuidedSegsearchStillGoing() const
bool Classified(int col, int row, int wildcard_id) const
WERD_CHOICE * best_choice
void DoSegSearch(WERD_RES *word_res)
bool Valid(const MATRIX &m) const
void InitForWord(const WERD_CHOICE *prev_word, bool fixed_pitch, float max_char_wh_ratio, float rating_cert_scale)
GenericVector< SEAM * > seam_array
bool ChoiceIsCorrect(const WERD_CHOICE *word_choice) const
LMPainPointsType Deque(MATRIX_COORD *pp, float *priority)
bool SegSearchDone(int num_futile_classifications)
void GenerateFromAmbigs(const DANGERR &fixpt, ViterbiStateEntry *vse, WERD_RES *word_res)
void put(ICOORD pos, const T &thing)
void UpdateSegSearchNodes(float rating_cert_scale, int starting_col, GenericVector< SegSearchPending > *pending, WERD_RES *word_res, LMPainPoints *pain_points, BestChoiceBundle *best_choice_bundle, BlamerBundle *blamer_bundle)
DANGERR fixpt
Places to try to fix the word suggested by ambiguity checking.
void InitBlamerForSegSearch(WERD_RES *word_res, LMPainPoints *pain_points, BlamerBundle *blamer_bundle, STRING *blamer_debug)
void print_ratings_list(const char *msg, BLOB_CHOICE_LIST *ratings, const UNICHARSET ¤t_unicharset)
bool assume_fixed_pitch_char_segment
void ResetNGramSearch(WERD_RES *word_res, BestChoiceBundle *best_choice_bundle, GenericVector< SegSearchPending > *pending)
LanguageModel * language_model_
bool wordrec_debug_blamer
void GenerateFromPath(float rating_cert_scale, ViterbiStateEntry *vse, WERD_RES *word_res)
bool GeneratePainPoint(int col, int row, LMPainPointsType pp_type, float special_priority, bool ok_to_extend, float max_char_wh_ratio, WERD_RES *word_res)
void SegSearch(WERD_RES *word_res, BestChoiceBundle *best_choice_bundle, BlamerBundle *blamer_bundle)
double segsearch_max_char_wh_ratio
WERD_CHOICE * prev_word_best_choice_
int segsearch_debug_level
static const char * PainPointDescription(LMPainPointsType type)
void GenerateInitial(WERD_RES *word_res)
void InitForSegSearch(const WERD_CHOICE *best_choice, MATRIX *ratings, UNICHAR_ID wildcard_id, bool debug, STRING *debug_str, TessResultCallback2< bool, int, int > *pp_cb)
void InitialSegSearch(WERD_RES *word_res, LMPainPoints *pain_points, GenericVector< SegSearchPending > *pending, BestChoiceBundle *best_choice_bundle, BlamerBundle *blamer_bundle)
void SetChopperBlame(const WERD_RES *word, bool debug)
void improve_by_chopping(float rating_cert_scale, WERD_RES *word, BestChoiceBundle *best_choice_bundle, BlamerBundle *blamer_bundle, LMPainPoints *pain_points, GenericVector< SegSearchPending > *pending)
bool GuidedSegsearchNeeded(const WERD_CHOICE *best_choice) const
int segsearch_max_pain_points
ViterbiStateEntry * best_vse
Best ViterbiStateEntry and BLOB_CHOICE.
void print(const UNICHARSET &unicharset) const
void init_to_size(int size, T t)
void ProcessSegSearchPainPoint(float pain_point_priority, const MATRIX_COORD &pain_point, const char *pain_point_type, GenericVector< SegSearchPending > *pending, WERD_RES *word_res, LMPainPoints *pain_points, BlamerBundle *blamer_bundle)