28#define MAX_UNDIVIDED_LENGTH 24
38 if (wordrec_skip_no_truth_words &&
41 if (classify_debug_level) {
42 tprintf(
"No truth for word - skipping\n");
54 tprintf(
"Not all words have valid states relative to ratings matrix!!");
58 if (tessedit_override_permuter) {
106 "recog_word: Discarded long string \"%s\""
107 " (%d characters vs %d blobs)\n",
128 int bestgap = -INT32_MAX;
133 int gap = blob_box.
left() - prev_box.
right();
143 split_word(word, split_index, &word2, &orig_bb);
165 ASSERT_HOST(split_pt > 0 && split_pt < word->chopped_word->NumBlobs());
175 auto *chopped2 =
new TWERD;
177 for (
auto i = split_pt;
i < chopped->
NumBlobs(); ++
i) {
178 chopped2->blobs.push_back(chopped->
blobs[
i]);
180 chopped->
blobs.resize(split_pt);
182 delete word2->chopped_word;
183 word2->chopped_word =
nullptr;
187 word2->ClearResults();
189 word2->chopped_word = chopped2;
191 word2->SetupBasicsFromChoppedWord(
unicharset);
194 if (orig_bb !=
nullptr) {
200 word2->chopped_word->blobs[0]->bounding_box().left(), wordrec_debug_blamer,
204 *right_piece = word2;
205 *orig_blamer_bundle = orig_bb;
225 split_pt.
x = (prev_box.
right() + blob_box.
left()) / 2;
226 split_pt.
y = (prev_box.
top() + prev_box.
bottom() + blob_box.
top() + blob_box.
bottom()) / 4;
246 const int kAltsPerPiece = 2;
248 const int kTooManyAltChoices = 100;
251 WERD_CHOICE_LIST joined_choices;
252 WERD_CHOICE_IT jc_it(&joined_choices);
256 int total_joined_choices = num_word1_choices;
262 for (bc2_it.forward(); !bc2_it.at_first(); bc2_it.forward(), ++bc2_index) {
263 if (total_joined_choices >= kTooManyAltChoices && bc2_index > kAltsPerPiece) {
267 for (bc1_it.move_to_first(); bc1_index < num_word1_choices; ++bc1_index, bc1_it.forward()) {
268 if (total_joined_choices >= kTooManyAltChoices && bc1_index > kAltsPerPiece) {
272 *wc += *bc2_it.data();
273 jc_it.add_after_then_move(wc);
274 ++total_joined_choices;
279 bc1_it.move_to_first();
280 bc2_it.move_to_first();
281 for (bc1_it.mark_cycle_pt(); !bc1_it.cycled_list(); bc1_it.forward()) {
282 *bc1_it.data() += *bc2_it.data();
284 bc1_it.move_to_last();
285 bc1_it.add_list_after(&joined_choices);
289 if (orig_bb !=
nullptr) {
#define MAX_UNDIVIDED_LENGTH
void tprintf(const char *format,...)
int16_t alpha_count(const char *word, const char *word_lengths)
void split_word(WERD_RES *word, unsigned split_pt, WERD_RES **right_piece, BlamerBundle **orig_blamer_bundle) const
void split_and_recog_word(WERD_RES *word)
void recog_word_recursive(WERD_RES *word)
void join_words(WERD_RES *word, WERD_RES *word2, BlamerBundle *orig_bb) const
void recog_word(WERD_RES *word)
void SplitBundle(int word1_right, int word2_left, bool debug, BlamerBundle *bundle1, BlamerBundle *bundle2) const
void JoinBlames(const BlamerBundle &bundle1, const BlamerBundle &bundle2, bool debug)
IncorrectResultReason incorrect_result_reason() const
std::vector< TBLOB * > blobs
unsigned NumBlobs() const
void AttachOnCorner(BandTriMatrix< T > *array2)
WERD_CHOICE * best_choice
BlamerBundle * blamer_bundle
const UNICHARSET * uch_set
WERD_CHOICE_LIST best_choices
std::vector< int > best_state
tesseract::BoxWord * box_word
std::vector< int > blob_widths
void DebugWordChoices(bool debug, const char *word_to_debug)
std::vector< int > blob_gaps
void SetupBasicsFromChoppedWord(const UNICHARSET &unicharset_in)
std::vector< SEAM * > seam_array
void make_bad()
Set the fields in this choice to be default (bad) values.
void set_permuter(uint8_t perm)
const std::string & unichar_lengths() const
void append_unichar_id(UNICHAR_ID unichar_id, int blob_count, float rating, float certainty)
std::string & unichar_string()
TDimension bottom() const
void rej_word_tess_failure()
void initialise(uint16_t length)
TBOX bounding_box() const
UNICHAR_ID unichar_to_id(const char *const unichar_repr) const
int dict_word(const WERD_CHOICE &word)
void cc_recog(WERD_RES *word)