50 #define MIN_FONT_ROW_COUNT 8 51 #define MAX_XHEIGHT_DIFF 3 71 TBOX &selection_box) {
100 tprintf(
"\n%d chars; word_blob_quality: %d; outline_errs: %d; " 101 "char_quality: %d; good_char_quality: %d\n",
125 const TBOX& target_word_box,
126 const char* word_config,
128 if (word_config !=
NULL) {
130 if (backup_config_file_ ==
NULL) {
132 FILE* config_fp = fopen(backup_config_file_,
"wb");
140 if (backup_config_file_ !=
NULL) {
144 backup_config_file_ =
NULL;
147 }
else if (pass > 1 && !word_box.
major_overlap(target_word_box)) {
155 const TBOX* target_word_box,
156 const char* word_config,
163 if (target_word_box ==
NULL ||
165 *target_word_box, word_config, 1)) {
170 for (
int w = 0; w < words->
size(); ++w) {
172 if (w > 0) (*words)[w].prev_word = &(*words)[w - 1];
178 if (pass_n == 1 || !word->
word->
done) {
186 }
else if (pass_n == 2) {
193 for (
int s = 0; s <= sub_langs_.size(); ++s) {
195 Tesseract* lang_t = s < sub_langs_.size() ? sub_langs_[s] :
this;
222 for (
int w = 0; w < words->
size(); ++w) {
224 if (w > 0) word->
prev_word = &(*words)[w - 1];
225 if (monitor !=
NULL) {
235 for (; w < words->
size(); ++w) {
252 bool make_next_word_fuzzy =
false;
260 tprintf(
"Pass%d: %s [%s]\n", pass_n,
265 if (make_next_word_fuzzy && pr_it->
word() !=
NULL) {
295 const TBOX* target_word_box,
296 const char* word_config,
305 if (dopasses==0 || dopasses==1) {
319 for (
int i = 0; i < sub_langs_.size(); ++i) {
321 sub_langs_[i]->SwitchAdaptiveClassifier();
323 sub_langs_[i]->StartBackupAdaptiveClassifier();
343 most_recently_used_ =
this;
368 if (dopasses == 1)
return true;
379 most_recently_used_ =
this;
402 #ifndef ANDROID_BUILD 442 if (monitor !=
NULL) {
459 if (!word_it.
word())
break;
466 tprintf(
"Skipping because one of the words is W_REP_CHAR\n");
491 tprintf(
"Top choice \"%s %s\" verified by bigram model.\n",
497 tprintf(
"Examining alt choices for \"%s %s\".\n",
508 float best_rating = 0.0;
511 for (prev_it.mark_cycle_pt(); !prev_it.cycled_list(); prev_it.forward()) {
520 for (w_it.mark_cycle_pt(); !w_it.cycled_list(); w_it.forward()) {
531 if (overrides_word1.
size() == 1 ||
534 best_idx = overrides_word1.
size() - 1;
539 if (overrides_word1.
size() >= 1) {
542 *overrides_word1[best_idx]) &&
544 *overrides_word2[best_idx])) {
546 tprintf(
"Top choice \"%s %s\" verified (sans case) by bigram " 547 "model.\n", orig_w1_str.
string(), orig_w2_str.
string());
551 STRING new_w1_str = overrides_word1[best_idx]->unichar_string();
552 STRING new_w2_str = overrides_word2[best_idx]->unichar_string();
553 if (new_w1_str != orig_w1_str) {
556 if (new_w2_str != orig_w2_str) {
560 STRING choices_description;
561 int num_bigram_choices
562 = overrides_word1.
size() * overrides_word2.
size();
563 if (num_bigram_choices == 1) {
564 choices_description =
"This was the unique bigram choice.";
568 const int kMaxChoicesToPrint = 20;
569 for (
int i = 0; i < overrides_word1.
size() &&
570 i < kMaxChoicesToPrint; i++) {
571 if (i > 0) { bigrams_list +=
", "; }
575 if (i == kMaxChoicesToPrint) {
576 bigrams_list +=
" ...";
579 choices_description =
"There were many choices: {";
580 choices_description += bigrams_list;
581 choices_description +=
"}";
583 choices_description.
add_str_int(
"There were ", num_bigram_choices);
584 choices_description +=
" compatible bigrams.";
587 tprintf(
"Replaced \"%s %s\" with \"%s %s\" with bigram model. %s\n",
590 choices_description.
string());
598 const TBOX* target_word_box,
599 const char* word_config) {
608 if (monitor !=
NULL) {
621 if (target_word_box &&
623 *target_word_box, word_config, 4)) {
637 inT16 all_char_quality;
638 inT16 accepted_all_char_quality;
640 &all_char_quality, &accepted_all_char_quality);
651 (blob_quality == 0) && (outline_errs >= chars_in_word))
659 (
"QUALITY: num_chs= %d num_rejs= %d %5.3f blob_qual= %d %5.3f" 660 " outline_errs= %d %5.3f char_qual= %d %5.3f good_ch_qual= %d %5.3f\n",
674 BOOL8 good_quality_doc =
704 static_cast<IncorrectResultReason>(bl)),
726 float word_x_height = word->
x_height;
727 if (word_x_height < word->best_choice->min_x_height() ||
735 double small_cap_delta = (x_height - small_cap_xheight) / 2.0;
737 small_cap_xheight - small_cap_delta <= word_x_height &&
738 word_x_height <= small_cap_xheight + small_cap_delta) {
748 if (num_upper > 0 && num_lower == 0)
758 float* rating,
float* certainty,
bool* bad,
759 bool* valid_permuter,
int* right,
int* next_left) {
762 if (index < words.
size()) {
764 if (choice ==
NULL) {
767 *rating += choice->
rating();
770 *valid_permuter =
false;
772 *right = words[index]->word->bounding_box().right();
773 if (index + 1 < words.
size())
774 *next_left = words[index + 1]->word->bounding_box().left();
776 *valid_permuter =
false;
788 static int SelectBestWords(
double rating_ratio,
789 double certainty_margin,
798 int num_best = 0, num_new = 0;
799 while (b < best_words->size() || n < new_words->size()) {
801 int start_b = b, start_n = n;
803 float b_rating = 0.0f, n_rating = 0.0f;
805 float b_certainty = 0.0f, n_certainty = 0.0f;
807 bool b_bad =
false, n_bad =
false;
809 bool b_valid_permuter =
true, n_valid_permuter =
true;
811 while (b < best_words->size() || n < new_words->size()) {
814 EvaluateWord(*best_words, b, &b_rating, &b_certainty, &b_bad,
815 &b_valid_permuter, &b_right, &next_b_left);
818 EvaluateWord(*new_words, n, &n_rating, &n_certainty, &n_bad,
819 &n_valid_permuter, &n_right, &next_n_left);
820 if (
MAX(b_right, n_right) <
MIN(next_b_left, next_n_left)) {
825 if ((b_right < n_right && b < best_words->size()) ||
826 n == new_words->
size())
831 bool new_better =
false;
832 if (!n_bad && (b_bad || (n_certainty > b_certainty &&
833 n_rating < b_rating) ||
834 (!b_valid_permuter && n_valid_permuter &&
835 n_rating < b_rating * rating_ratio &&
836 n_certainty > b_certainty - certainty_margin))) {
838 for (
int i = start_n; i <= n; ++i) {
840 (*new_words)[i] =
NULL;
846 for (
int i = start_b; i <= b; ++i) {
848 (*best_words)[i] =
NULL;
852 int end_b = b < best_words->
size() ? b + 1 : b;
853 int end_n = n < new_words->
size() ? n + 1 : n;
855 tprintf(
"%d new words %s than %d old words: r: %g v %g c: %g v %g" 856 " valid dict: %d v %d\n",
857 end_n - start_n, new_better ?
"better" :
"worse",
858 end_b - start_b, n_rating, b_rating,
859 n_certainty, b_certainty, n_valid_permuter, b_valid_permuter);
867 for (
int i = 0; i < out_words.
size(); ++i)
869 return num_new - num_best;
881 tprintf(
"Trying word using lang %s, oem %d\n",
886 (this->*recognizer)(word_data, in_word, &new_words);
887 if (new_words.
empty()) {
894 for (
int i = 0; i < new_words.
size(); ++i)
895 new_words[i]->DebugTopChoice(
"Lang result");
902 debug, &new_words, best_words);
907 for (
int w = 0; w < words.
size(); ++w) {
908 if (words[w]->tess_failed || !words[w]->tess_accepted)
return false;
917 bool* make_next_word_fuzzy) {
918 *make_next_word_fuzzy =
false;
932 &word_wanted, &overlapped_any_blob,
940 int num_overlapped = 0;
941 int num_overlapped_used = 0;
942 for (
int i = 0; i < overlapped_any_blob.
size(); ++i) {
943 if (overlapped_any_blob[i]) {
945 if (word_wanted[i]) ++num_overlapped_used;
955 int non_overlapped = 0;
956 int non_overlapped_used = 0;
957 for (
int i = 0; i < word_wanted.
size(); ++i) {
958 if (word_wanted[i]) ++non_overlapped_used;
959 if (outlines[i] !=
NULL) ++non_overlapped_used;
962 tprintf(
"Used %d/%d overlapped %d/%d non-overlaped diacritics on word:",
963 num_overlapped_used, num_overlapped, non_overlapped_used,
969 make_next_word_fuzzy)) {
974 return num_overlapped_used != 0 || non_overlapped_used != 0;
996 for (blob_it.mark_cycle_pt(); !blob_it.cycled_list(); blob_it.forward()) {
997 C_BLOB* blob = blob_it.data();
1000 int num_blob_outlines = 0;
1001 for (
int i = 0; i < outlines.
size(); ++i) {
1003 !(*word_wanted)[i]) {
1004 blob_wanted[i] =
true;
1005 (*overlapped_any_blob)[i] =
true;
1006 ++num_blob_outlines;
1010 tprintf(
"%d noise outlines overlap blob at:", num_blob_outlines);
1019 outlines, num_blob_outlines,
1021 for (
int i = 0; i < blob_wanted.
size(); ++i) {
1022 if (blob_wanted[i]) {
1024 (*word_wanted)[i] =
true;
1025 (*target_blobs)[i] = blob;
1043 for (
int i = 0; i < outlines.
size(); ++i) {
1044 if (outlines[i] ==
NULL)
continue;
1047 int num_blob_outlines = 0;
1048 TBOX total_ol_box(outlines[i]->bounding_box());
1049 while (i < outlines.
size() && outlines[i] !=
NULL) {
1050 blob_wanted[i] =
true;
1051 total_ol_box += outlines[i]->bounding_box();
1053 ++num_blob_outlines;
1057 while (!blob_it.at_last() &&
1058 blob_it.data_relative(1)->bounding_box().left() <=
1059 total_ol_box.
left()) {
1065 tprintf(
"Num blobless outlines = %d\n", num_blob_outlines);
1066 C_BLOB* left_blob = blob_it.data();
1068 C_BLOB* right_blob = blob_it.at_last() ?
NULL : blob_it.data_relative(1);
1069 if ((left_box.
x_overlap(total_ol_box) || right_blob ==
NULL ||
1072 outlines, num_blob_outlines,
1075 for (
int j = 0; j < blob_wanted.
size(); ++j) {
1076 if (blob_wanted[j]) {
1077 (*word_wanted)[j] =
true;
1078 (*target_blobs)[j] = left_blob;
1081 }
else if (right_blob !=
NULL &&
1085 right_blob, outlines,
1086 num_blob_outlines, &blob_wanted)) {
1088 for (
int j = 0; j < blob_wanted.
size(); ++j) {
1089 if (blob_wanted[j]) {
1090 (*word_wanted)[j] =
true;
1091 (*target_blobs)[j] = right_blob;
1095 outlines, num_blob_outlines,
1098 for (
int j = 0; j < blob_wanted.
size(); ++j) {
1099 if (blob_wanted[j]) {
1100 (*word_wanted)[j] =
true;
1101 (*target_blobs)[j] =
NULL;
1116 float target_cert = certainty_threshold;
1121 tprintf(
"No Noise blob classified as %s=%g(%g) at:", best_str.
string(),
1122 target_cert, target_c2);
1132 pr_it, blob, &all_str);
1135 for (
int i = 0; i < test_outlines.
size(); ++i) {
1136 if (test_outlines[i]) ol_box += outlines[i]->bounding_box();
1138 tprintf(
"All Noise blob classified as %s=%g, delta=%g at:",
1139 all_str.
string(), best_cert, best_cert - target_cert);
1145 while (num_outlines > 1 && best_index >= 0 &&
1146 (blob ==
NULL || best_cert < target_cert || blob !=
NULL)) {
1149 for (
int i = 0; i < outlines.
size(); ++i) {
1150 if (test_outlines[i]) {
1151 test_outlines[i] =
false;
1157 for (
int j = 0; j < outlines.
size(); ++j) {
1158 if (test_outlines[j]) ol_box += outlines[j]->bounding_box();
1159 tprintf(
"%d", test_outlines[j]);
1161 tprintf(
" blob classified as %s=%g, delta=%g) at:", str.
string(),
1162 cert, cert - target_cert);
1165 if (cert > best_cert) {
1168 best_outlines = test_outlines;
1170 test_outlines[i] =
true;
1173 if (best_index >= 0) {
1174 test_outlines[best_index] =
false;
1178 if (best_cert >= target_cert) {
1180 *ok_outlines = best_outlines;
1182 tprintf(
"%s noise combination ", blob ?
"Adding" :
"New");
1183 for (
int i = 0; i < best_outlines.
size(); ++i) {
1184 tprintf(
"%d", best_outlines[i]);
1186 tprintf(
" yields certainty %g, beating target of %g\n", best_cert,
1204 ol_it.set_to_list(blob->
out_list());
1205 first_to_keep = ol_it.data();
1207 for (
int i = 0; i < ok_outlines.
size(); ++i) {
1208 if (ok_outlines[i]) {
1211 blob =
new C_BLOB(outlines[i]);
1212 ol_it.set_to_list(blob->
out_list());
1214 ol_it.add_before_stay_put(outlines[i]);
1220 ol_it.move_to_first();
1221 if (first_to_keep ==
NULL) {
1223 for (; !ol_it.empty(); ol_it.forward()) ol_it.extract();
1228 for (; ol_it.data() != first_to_keep; ol_it.forward()) {
1253 tprintf(
"word xheight=%g, row=%g, range=[%g,%g]\n", word_res->
x_height,
1254 wd.row->x_height(), wd.word->raw_choice->min_x_height(),
1255 wd.word->raw_choice->max_x_height());
1257 float cert = wd.word->raw_choice->certainty();
1258 float rat = wd.word->raw_choice->rating();
1259 *c2 = rat > 0.0f ? cert * cert / rat : 0.0f;
1260 *best_str = wd.word->raw_choice->unichar_string();
1282 clock_t start_t = clock();
1284 tprintf(
"%s word with lang %s at:",
1285 word->
done ?
"Already done" :
"Processing",
1295 int sub = sub_langs_.size();
1296 if (most_recently_used_ !=
this) {
1298 for (sub = 0; sub < sub_langs_.size() &&
1299 most_recently_used_ != sub_langs_[sub]; ++sub) {}
1302 *word_data, recognizer, &word_data->
lang_words[sub], &best_words);
1303 Tesseract* best_lang_tess = most_recently_used_;
1304 if (!WordsAcceptable(best_words)) {
1306 if (most_recently_used_ !=
this &&
1310 best_lang_tess =
this;
1312 for (
int i = 0; !WordsAcceptable(best_words) && i < sub_langs_.size();
1314 if (most_recently_used_ != sub_langs_[i] &&
1318 best_lang_tess = sub_langs_[i];
1322 most_recently_used_ = best_lang_tess;
1323 if (!best_words.
empty()) {
1324 if (best_words.
size() == 1 && !best_words[0]->combination) {
1329 word_data->
word = best_words.
back();
1336 clock_t ocr_t = clock();
1338 tprintf(
"%s (ocr took %.2f sec)\n",
1340 static_cast<double>(ocr_t-start_t)/CLOCKS_PER_SEC);
1353 ROW* row = word_data.
row;
1357 #ifndef ANDROID_BUILD 1389 tprintf(
"New XHT Match:%s = %s ",
1400 new_x_ht > 0.1 ?
"STILL DOUBT" :
"OK",
1401 accept_new_word ?
"ACCEPTED" :
"");
1409 bool accept_new_x_ht =
false;
1411 if (original_misfits == 0)
1413 float baseline_shift = 0.0f;
1415 if (baseline_shift != 0.0f) {
1421 if (original_misfits > 0) {
1422 float new_baseline_shift;
1444 float baseline_shift,
float new_x_ht,
1446 bool accept_new_x_ht =
false;
1463 tprintf(
"Old misfits=%d with x-height %f, new=%d with x-height %f\n",
1465 new_misfits, new_x_ht);
1466 tprintf(
"Old rating= %f, certainty=%f, new=%f, %f\n",
1472 accept_new_x_ht = new_misfits < original_misfits &&
1481 if (accept_new_x_ht) {
1505 ROW* row = word_data.
row;
1532 #ifndef GRAPHICS_DISABLED 1567 tprintf(
"POST FIX_QUOTES FAIL String:\"%s\"; Strlen=%d;" 1594 if (choice !=
NULL) {
1596 best_choice = choice;
1605 static void CorrectRepcharChoices(
BLOB_CHOICE* blob_choice,
1611 if (choice ==
NULL) {
1613 choice_it.add_before_stay_put(
new BLOB_CHOICE(*blob_choice));
1617 for (
int i = 0; i < word->
length(); ++i) {
1636 for (
int i = 0; i < word.
length(); ++i) {
1642 int max_count = rep_ch.MaxCount(&maxch_id);
1644 BLOB_CHOICE* best_choice = FindBestMatchingChoice(maxch_id, word_res);
1645 if (best_choice ==
NULL) {
1646 tprintf(
"Failed to find a choice for %s, occurring %d times\n",
1656 C_BLOB* prev_blob = blob_it.data();
1657 for (blob_it.forward(); !blob_it.at_first(); blob_it.forward()) {
1658 C_BLOB* blob = blob_it.data();
1660 gap -= prev_blob->bounding_box().right();
1665 CorrectRepcharChoices(best_choice, word_res);
1670 const UNICHARSET& char_set,
const char *s,
const char *lengths) {
1673 int leading_punct_count;
1674 int upper_count = 0;
1675 int hyphen_pos = -1;
1678 if (strlen (lengths) > 20)
1684 offset += lengths[i++];
1685 leading_punct_count = i;
1688 while (s[offset] !=
'\0' && char_set.
get_isupper(s + offset, lengths[i])) {
1689 offset += lengths[i++];
1692 if (upper_count > 1) {
1696 while (s[offset] !=
'\0' && char_set.
get_islower(s + offset, lengths[i])) {
1697 offset += lengths[i++];
1705 if (lengths[i] == 1 && s[offset] ==
'-') {
1707 offset += lengths[i++];
1708 if (s[offset] !=
'\0') {
1709 while ((s[offset] !=
'\0') &&
1711 offset += lengths[i++];
1713 if (i < hyphen_pos + 3)
1718 if (lengths[i] == 1 && (s[offset] ==
'\'') &&
1719 lengths[i + 1] == 1 && (s[offset + lengths[i]] ==
's')) {
1720 offset += lengths[i++];
1721 offset += lengths[i++];
1724 if (upper_count > 0)
1731 if (lengths[i] == 1 && s[offset] !=
'\0' &&
1733 offset += lengths[i++];
1734 if (lengths[i] == 1 && s[offset] !=
'\0' && i > 0 &&
1735 s[offset - lengths[i - 1]] != s[offset] &&
1737 offset += lengths[i++];
1739 if (s[offset] !=
'\0')
1748 if (s[0] !=
'\0' && char_set.
get_isupper(s, lengths[0])) {
1750 while (s[offset] !=
'\0' &&
1752 lengths[i + 1] == 1 && s[offset + lengths[i]] ==
'.') {
1753 offset += lengths[i++];
1754 offset += lengths[i++];
1757 else if (s[0] !=
'\0' && char_set.
get_islower(s, lengths[0])) {
1759 while (s[offset] !=
'\0' &&
1761 lengths[i + 1] == 1 && s[offset + lengths[i]] ==
'.') {
1762 offset += lengths[i++];
1763 offset += lengths[i++];
1766 if (s[offset] !=
'\0')
1791 tprintf (
"classify_word_pass1 start\n");
1795 tprintf (
"make_reject_map: initial map");
1798 tprintf (
"make_reject_map: after NN");
1801 tprintf (
"classify_word_pass2 - START");
1804 tprintf (
"classify_word_pass2 - Pre Xht");
1807 tprintf (
"classify_word_pass2 - END");
1808 show_map_detail =
TRUE;
1820 tprintf (
"After Poor quality rejection");
1823 tprintf (
"unrej_good_quality_words - START");
1826 tprintf (
"unrej_good_quality_words - END");
1829 tprintf (
"Write results pass");
1830 show_map_detail =
TRUE;
1837 if (show_map_detail) {
1845 tprintf(
"null best choice\n");
1848 tprintf (
"Done flag: %s\n\n", word->
done ?
"TRUE" :
"FALSE");
1860 static void find_modal_font(
1873 fonts->
add (font, -*font_count);
1893 if (fontinfo_size == 0)
return;
1901 tprintf(
"Examining fonts in %s\n",
1906 if (choice ==
NULL)
continue;
1908 for (
int f = 0; f < fonts.
size(); ++f) {
1909 int fontinfo_id = fonts[f].fontinfo_id;
1910 if (0 <= fontinfo_id && fontinfo_id < fontinfo_size) {
1911 font_total_score[fontinfo_id] += fonts[f].score;
1916 int score1 = 0, score2 = 0;
1917 inT16 font_id1 = -1, font_id2 = -1;
1918 for (
int f = 0; f < fontinfo_size; ++f) {
1920 tprintf(
"Font %s, total score = %d\n",
1923 if (font_total_score[f] > score1) {
1925 font_id2 = font_id1;
1926 score1 = font_total_score[f];
1928 }
else if (font_total_score[f] > score2) {
1929 score2 = font_total_score[f];
1943 tprintf(
"Word modal font=%s, score=%d, 2nd choice %s/%d\n",
1948 tprintf(
"Word modal font=%s, score=%d. No 2nd choice\n",
1967 STATS doc_fonts(0, font_table_size_);
1972 word = page_res_it.
word();
1981 inT8 doc_font_count;
1982 find_modal_font(&doc_fonts, &doc_font, &doc_font_count);
1983 if (doc_font_count == 0)
1989 word = page_res_it.
word();
2004 word = page_res_it.
word();
2008 if (!(count == length || (length > 3 && count >= length * 3 / 4))) {
2025 if (word->best_choices.singleton())
2029 if (word->tesseract->getDict().valid_word(*best) != 0)
2032 WERD_CHOICE_IT choice_it(&word->best_choices);
2033 for (choice_it.mark_cycle_pt(); !choice_it.cycled_list();
2034 choice_it.forward()) {
2036 if (word->tesseract->getDict().valid_word(*alternate)) {
2039 tprintf(
"Dictionary correction replaces best choice '%s' with '%s'\n",
2044 word->ReplaceBestChoice(alternate);
int tessedit_ocr_engine_mode
void add(inT32 value, inT32 count)
BLOB_CHOICE_LIST * GetBlobChoices(int index) const
int CountMisfitTops(WERD_RES *word_res)
void LearnWord(const char *fontname, WERD_RES *word)
TBOX bounding_box() const
void InitForRetryRecognition(const WERD_RES &source)
bool SetupForRecognition(const UNICHARSET &unicharset_in, tesseract::Tesseract *tesseract, Pix *pix, int norm_mode, const TBOX *norm_box, bool numeric_mode, bool use_body_size, bool allow_detailed_fx, ROW *row, const BLOCK *block)
void ReplaceBestChoice(WERD_CHOICE *choice)
const GenericVector< tesseract::ScoredFont > & fonts() const
int tessedit_bigram_debug
BOOL8 flag(WERD_FLAGS mask) const
void ConsumeWordResults(WERD_RES *word)
WERD * ConstructFromSingleBlob(bool bol, bool eol, C_BLOB *blob)
void set_global_subloc_code(int loc_code)
static void LastChanceBlame(bool debug, WERD_RES *word)
bool tessedit_minimal_rejection
const double kRepcharGapThreshold
void(Tesseract::* WordRecognizer)(const WordData &word_data, WERD_RES **in_word, PointerVector< WERD_RES > *out_words)
void SetupWordPassN(int pass_n, WordData *word)
WERD_CHOICE shallow_copy(int start, int end) const
static int SortByXMiddle(const void *v1, const void *v2)
inT16 word_blob_quality(WERD_RES *word, ROW *row)
void tess_add_doc_word(WERD_CHOICE *word_choice)
TBOX bounding_box() const
int RetryWithLanguage(const WordData &word_data, WordRecognizer recognizer, WERD_RES **in_word, PointerVector< WERD_RES > *best_words)
const double kMinRefitXHeightFraction
static void PrintParams(FILE *fp, const ParamsVectors *member_params)
bool tessedit_debug_quality_metrics
static C_BLOB * deep_copy(const C_BLOB *src)
BlamerBundle * blamer_bundle
void cube_word_pass1(BLOCK *block, ROW *row, WERD_RES *word)
C_BLOB_LIST * cblob_list()
void ReportXhtFixResult(bool accept_new_word, float new_x_ht, WERD_RES *word, WERD_RES *new_word)
void match_word_pass_n(int pass_n, WERD_RES *word, ROW *row, BLOCK *block)
void full_print(FILE *fp)
GenericVector< STRING > misadaption_log
BOOL8 word_adaptable(WERD_RES *word, uinT16 mode)
WERD_RES * restart_page()
const STRING & misadaption_debug() const
static bool valid_word_permuter(uinT8 perm, bool numbers_ok)
Check all the DAWGs to see if this word is in any of them.
ACCEPTABLE_WERD_TYPE acceptable_word_string(const UNICHARSET &char_set, const char *s, const char *lengths)
void word_char_quality(WERD_RES *word, ROW *row, inT16 *match_count, inT16 *accepted_match_count)
void rej_word_bad_quality()
PointerVector< WERD_RES > lang_words
STRING debug_str(UNICHAR_ID id) const
TBOX bounding_box() const
void classify_word_and_language(int pass_n, PAGE_RES_IT *pr_it, WordData *word_data)
bool tessedit_display_outwords
UnicityTable< FontInfo > & get_fontinfo_table()
inT16 doc_good_char_quality
WERD_CHOICE_LIST best_choices
bool tessedit_debug_fonts
void tess_segment_pass_n(int pass_n, WERD_RES *word)
const UNICHARSET * uch_set
float ClassifyBlobPlusOutlines(const GenericVector< bool > &ok_outlines, const GenericVector< C_OUTLINE * > &outlines, int pass_n, PAGE_RES_IT *pr_it, C_BLOB *blob, STRING *best_str)
BOOL8 check_debug_pt(WERD_RES *word, int location)
void StartBackupAdaptiveClassifier()
bool tessedit_minimal_rej_pass1
bool TestNewNormalization(int original_misfits, float baseline_shift, float new_x_ht, WERD_RES *word, BLOCK *block, ROW *row)
char * chs_trailing_punct1
bool tessedit_enable_doc_dict
const FontInfo * fontinfo
static const char * IncorrectReasonName(IncorrectResultReason irr)
void CleanupSingleRowResult(PageSegMode pageseg_mode, PAGE_RES *page_res)
static const double kXHeightCapRatio
tesseract::Tesseract * tesseract
GenericVector< int > blame_reasons
void dictionary_correction_pass(PAGE_RES *page_res)
void SetMisAdaptionDebug(const WERD_CHOICE *best_choice, bool debug)
const UNICHAR_ID unichar_id(int index) const
bool SelectGoodDiacriticOutlines(int pass, float certainty_threshold, PAGE_RES_IT *pr_it, C_BLOB *blob, const GenericVector< C_OUTLINE * > &outlines, int num_outlines, GenericVector< bool > *ok_outlines)
void ReplaceCurrentWord(tesseract::PointerVector< WERD_RES > *words)
void script_pos_pass(PAGE_RES *page_res)
BOOL8 contains(const char c) const
bool SubAndSuperscriptFix(WERD_RES *word_res)
void fix_rep_char(PAGE_RES_IT *page_res_it)
void AssignDiacriticsToOverlappingBlobs(const GenericVector< C_OUTLINE * > &outlines, int pass, WERD *real_word, PAGE_RES_IT *pr_it, GenericVector< bool > *word_wanted, GenericVector< bool > *overlapped_any_blob, GenericVector< C_BLOB * > *target_blobs)
void PrerecAllWordsPar(const GenericVector< WordData > &words)
void initialise(inT16 length)
void run_cube_combiner(PAGE_RES *page_res)
bool tess_acceptable_word(WERD_RES *word)
void fix_fuzzy_spaces(ETEXT_DESC *monitor, inT32 word_count, PAGE_RES *page_res)
bool major_overlap(const TBOX &box) const
double noise_cert_basechar
bool AdaptiveClassifierIsFull() const
bool textord_use_cjk_fp_model
float max_x_height() const
void GetNoiseOutlines(GenericVector< C_OUTLINE * > *outlines)
const char * string() const
float ClassifyBlobAsWord(int pass_n, PAGE_RES_IT *pr_it, C_BLOB *blob, STRING *best_str, float *c2)
int quality_min_initial_alphas_reqd
const STRING & unichar_string() const
bool tessedit_rejection_debug
const STRING debug_string() const
bool AdaptableWord(WERD_RES *word)
void Add(T value, int count)
void classify_word_pass1(const WordData &word_data, WERD_RES **in_word, PointerVector< WERD_RES > *out_words)
void blamer_pass(PAGE_RES *page_res)
void PrintBestChoices() const
IncorrectResultReason incorrect_result_reason() const
C_OUTLINE_LIST * out_list()
bool classify_bln_numeric_mode
bool ReassignDiacritics(int pass, PAGE_RES_IT *pr_it, bool *make_next_word_fuzzy)
void init_to_size(int size, T t)
const FontInfo * fontinfo2
void set_global_loc_code(int loc_code)
bool get_islower(UNICHAR_ID unichar_id) const
bool wordrec_debug_blamer
void rejection_passes(PAGE_RES *page_res, ETEXT_DESC *monitor, const TBOX *target_word_box, const char *word_config)
void bigram_correction_pass(PAGE_RES *page_res)
static bool ReadParamsFile(const char *file, SetParamConstraint constraint, ParamsVectors *member_params)
bool tessedit_enable_bigram_correction
BLOCK_RES * block() const
bool TrainedXheightFix(WERD_RES *word, BLOCK *block, ROW *row)
bool poly_allow_detailed_fx
bool ProcessTargetWord(const TBOX &word_box, const TBOX &target_word_box, const char *word_config, int pass)
FCOORD classify_rotation() const
double noise_cert_disjoint
WERD_CHOICE * prev_word_best_choice_
void AssignDiacriticsToNewBlobs(const GenericVector< C_OUTLINE * > &outlines, int pass, WERD *real_word, PAGE_RES_IT *pr_it, GenericVector< bool > *word_wanted, GenericVector< C_BLOB * > *target_blobs)
void MakeCurrentWordFuzzy()
void SetupAllWordsPassN(int pass_n, const TBOX *target_word_box, const char *word_config, PAGE_RES *page_res, GenericVector< WordData > *words)
void output_pass(PAGE_RES_IT &page_res_it, const TBOX *target_word_box)
PAGE_RES_IT * make_pseudo_word(PAGE_RES *page_res, const TBOX &selection_box)
BOOL8 recog_interactive(PAGE_RES_IT *pr_it)
int tessedit_tess_adaption_mode
bool tessedit_test_adaption
bool major_x_overlap(const TBOX &box) const
UnicityTable< FontInfo > fontinfo_table_
void BestChoiceToCorrectText()
bool tessedit_dump_choices
bool script_has_xheight() const
bool tessedit_enable_dict_correction
void make_reject_map(WERD_RES *word, ROW *row, inT16 pass)
C_BLOB_LIST * rej_cblob_list()
double classify_max_rating_ratio
double quality_outline_pc
EXTERN ScrollView * fx_win
bool RecogAllWordsPassN(int pass_n, ETEXT_DESC *monitor, PAGE_RES_IT *pr_it, GenericVector< WordData > *words)
void CopyTruth(const BlamerBundle &other)
bool top_bottom_useful() const
inT16 word_outline_errs(WERD_RES *word)
bool contains(const FCOORD pt) const
UNICHAR_ID unichar_id() const
void quality_based_rejection(PAGE_RES_IT &page_res_it, BOOL8 good_quality_doc)
double classify_max_certainty_margin
bool EqualIgnoringCaseAndTerminalPunct(const WERD_CHOICE &word1, const WERD_CHOICE &word2)
const char *const kBackUpConfigFile
char * chs_trailing_punct2
tesseract::BoxWord * box_word
bool AdaptiveClassifierIsEmpty() const
BLOB_CHOICE * FindMatchingChoice(UNICHAR_ID char_id, BLOB_CHOICE_LIST *bc_list)
T ClipToRange(const T &x, const T &lower_bound, const T &upper_bound)
void add_str_int(const char *str, int number)
bool recog_all_words(PAGE_RES *page_res, ETEXT_DESC *monitor, const TBOX *target_word_box, const char *word_config, int dopasses)
void GetNonSuperscriptSpan(int *start, int *end) const
bool valid_bigram(const WERD_CHOICE &word1, const WERD_CHOICE &word2) const
void recog_pseudo_word(PAGE_RES *page_res, TBOX &selection_box)
inT32 x_height() const
return xheight
bool right_to_left() const
inT32 pile_count(inT32 value) const
void set_word_fonts(WERD_RES *word)
WERD_CHOICE * best_choice
bool tessedit_fix_fuzzy_spaces
void ZoomToRectangle(int x1, int y1, int x2, int y2)
#define LOC_WRITE_RESULTS
bool deadline_exceeded() const
void classify_word_pass2(const WordData &word_data, WERD_RES **in_word, PointerVector< WERD_RES > *out_words)
bool x_overlap(const TBOX &box) const
void plot(ScrollView *window)
BLOB_CHOICE * GetBlobChoice(int index) const
float min_x_height() const
WERD_RES * InsertSimpleCloneWord(const WERD_RES &clone_res, WERD *new_word)
void SwitchAdaptiveClassifier()
bool tessedit_timing_debug
bool tessedit_fix_hyphens
bool get_isupper(UNICHAR_ID unichar_id) const
void font_recognition_pass(PAGE_RES *page_res)
void SetScriptPositions()
bool tessedit_word_for_word
bool tessedit_reject_bad_qual_wds
int tessedit_pageseg_mode
bool AddSelectedOutlines(const GenericVector< bool > &wanted, const GenericVector< C_BLOB * > &target_blobs, const GenericVector< C_OUTLINE * > &outlines, bool *make_next_word_fuzzy)
void set_unichar_id(UNICHAR_ID unichar_id, int index)
float ComputeCompatibleXheight(WERD_RES *word_res, float *baseline_shift)