23 #include "config_auto.h" 51 #define MIN_FONT_ROW_COUNT 8 52 #define MAX_XHEIGHT_DIFF 3 68 TBOX &selection_box) {
89 if (lstm_recognizer_ == NULL) {
97 tprintf(
"\n%d chars; word_blob_quality: %d; outline_errs: %d; " 98 "char_quality: %d; good_char_quality: %d\n",
122 const TBOX& target_word_box,
123 const char* word_config,
125 if (word_config != NULL) {
127 if (backup_config_file_ == NULL) {
129 FILE* config_fp = fopen(backup_config_file_,
"wb");
137 if (backup_config_file_ != NULL) {
141 backup_config_file_ = NULL;
144 }
else if (pass > 1 && !word_box.
major_overlap(target_word_box)) {
152 const TBOX* target_word_box,
153 const char* word_config,
160 if (target_word_box == NULL ||
162 *target_word_box, word_config, 1)) {
167 for (
int w = 0; w < words->
size(); ++w) {
169 if (w > 0) (*words)[w].prev_word = &(*words)[w - 1];
175 if (pass_n == 1 || !word->
word->
done) {
183 }
else if (pass_n == 2) {
190 for (
int s = 0; s <= sub_langs_.size(); ++s) {
192 Tesseract* lang_t = s < sub_langs_.size() ? sub_langs_[s] :
this;
219 for (
int w = 0; w < words->
size(); ++w) {
221 if (w > 0) word->
prev_word = &(*words)[w - 1];
222 if (monitor != NULL) {
241 for (; w < words->
size(); ++w) {
255 while (pr_it->
word() != NULL && pr_it->
word() != word->
word)
258 bool make_next_word_fuzzy =
false;
267 tprintf(
"Pass%d: %s [%s]\n", pass_n,
272 if (make_next_word_fuzzy && pr_it->
word() != NULL) {
302 const TBOX* target_word_box,
303 const char* word_config,
312 if (dopasses==0 || dopasses==1) {
326 for (
int i = 0; i < sub_langs_.size(); ++i) {
328 sub_langs_[i]->SwitchAdaptiveClassifier();
330 sub_langs_[i]->StartBackupAdaptiveClassifier();
350 most_recently_used_ =
this;
375 if (dopasses == 1)
return true;
386 most_recently_used_ =
this;
444 if (monitor != NULL) {
457 while (word_it.
forward() != NULL &&
461 if (!word_it.
word())
break;
468 tprintf(
"Skipping because one of the words is W_REP_CHAR\n");
493 tprintf(
"Top choice \"%s %s\" verified by bigram model.\n",
499 tprintf(
"Examining alt choices for \"%s %s\".\n",
510 float best_rating = 0.0;
513 for (prev_it.mark_cycle_pt(); !prev_it.cycled_list(); prev_it.forward()) {
522 for (w_it.mark_cycle_pt(); !w_it.cycled_list(); w_it.forward()) {
533 if (overrides_word1.
size() == 1 ||
536 best_idx = overrides_word1.
size() - 1;
541 if (!overrides_word1.
empty()) {
544 *overrides_word1[best_idx]) &&
546 *overrides_word2[best_idx])) {
548 tprintf(
"Top choice \"%s %s\" verified (sans case) by bigram " 549 "model.\n", orig_w1_str.
string(), orig_w2_str.
string());
553 STRING new_w1_str = overrides_word1[best_idx]->unichar_string();
554 STRING new_w2_str = overrides_word2[best_idx]->unichar_string();
555 if (new_w1_str != orig_w1_str) {
558 if (new_w2_str != orig_w2_str) {
562 STRING choices_description;
563 int num_bigram_choices
564 = overrides_word1.
size() * overrides_word2.
size();
565 if (num_bigram_choices == 1) {
566 choices_description =
"This was the unique bigram choice.";
570 const int kMaxChoicesToPrint = 20;
571 for (
int i = 0; i < overrides_word1.
size() &&
572 i < kMaxChoicesToPrint; i++) {
573 if (i > 0) { bigrams_list +=
", "; }
577 if (i == kMaxChoicesToPrint) {
578 bigrams_list +=
" ...";
581 choices_description =
"There were many choices: {";
582 choices_description += bigrams_list;
583 choices_description +=
"}";
585 choices_description.
add_str_int(
"There were ", num_bigram_choices);
586 choices_description +=
" compatible bigrams.";
589 tprintf(
"Replaced \"%s %s\" with \"%s %s\" with bigram model. %s\n",
592 choices_description.
string());
600 const TBOX* target_word_box,
601 const char* word_config) {
610 if (monitor != NULL) {
623 if (target_word_box &&
625 *target_word_box, word_config, 4)) {
639 inT16 all_char_quality;
640 inT16 accepted_all_char_quality;
642 &all_char_quality, &accepted_all_char_quality);
653 (blob_quality == 0) && (outline_errs >= chars_in_word))
661 (
"QUALITY: num_chs= %d num_rejs= %d %5.3f blob_qual= %d %5.3f" 662 " outline_errs= %d %5.3f char_qual= %d %5.3f good_ch_qual= %d %5.3f\n",
676 BOOL8 good_quality_doc =
706 static_cast<IncorrectResultReason>(bl)),
728 float word_x_height = word->
x_height;
729 if (word_x_height < word->best_choice->min_x_height() ||
737 double small_cap_delta = (x_height - small_cap_xheight) / 2.0;
739 small_cap_xheight - small_cap_delta <= word_x_height &&
740 word_x_height <= small_cap_xheight + small_cap_delta) {
750 if (num_upper > 0 && num_lower == 0)
762 if (index < words.
size()) {
763 *right = words[index]->word->bounding_box().right();
764 if (index + 1 < words.
size())
765 *next_left = words[index + 1]->word->bounding_box().left();
772 int first_index,
int end_index,
float* rating,
773 float* certainty,
bool* bad,
774 bool* valid_permuter) {
775 if (end_index <= first_index) {
777 *valid_permuter =
false;
779 for (
int index = first_index; index < end_index && index < words.
size();
782 if (choice ==
nullptr) {
785 *rating += choice->
rating();
788 *valid_permuter =
false;
800 static int SelectBestWords(
double rating_ratio,
801 double certainty_margin,
810 int num_best = 0, num_new = 0;
811 while (b < best_words->
size() || n < new_words->
size()) {
813 int start_b = b, start_n = n;
814 while (b < best_words->
size() || n < new_words->
size()) {
817 WordGap(*best_words, b, &b_right, &next_b_left);
820 WordGap(*new_words, n, &n_right, &next_n_left);
821 if (
MAX(b_right, n_right) <
MIN(next_b_left, next_n_left)) {
826 if ((b_right < n_right && b < best_words->
size()) ||
827 n == new_words->
size())
833 float b_rating = 0.0f, n_rating = 0.0f;
835 float b_certainty = 0.0f, n_certainty = 0.0f;
837 bool b_bad =
false, n_bad =
false;
839 bool b_valid_permuter =
true, n_valid_permuter =
true;
840 int end_b = b < best_words->
size() ? b + 1 : b;
841 int end_n = n < new_words->
size() ? n + 1 : n;
842 EvaluateWordSpan(*best_words, start_b, end_b, &b_rating, &b_certainty,
843 &b_bad, &b_valid_permuter);
844 EvaluateWordSpan(*new_words, start_n, end_n, &n_rating, &n_certainty,
845 &n_bad, &n_valid_permuter);
846 bool new_better =
false;
847 if (!n_bad && (b_bad || (n_certainty > b_certainty &&
848 n_rating < b_rating) ||
849 (!b_valid_permuter && n_valid_permuter &&
850 n_rating < b_rating * rating_ratio &&
851 n_certainty > b_certainty - certainty_margin))) {
853 for (
int i = start_n; i < end_n; ++i) {
855 (*new_words)[i] = NULL;
861 for (
int i = start_b; i < end_b; ++i) {
863 (*best_words)[i] = NULL;
868 tprintf(
"%d new words %s than %d old words: r: %g v %g c: %g v %g" 869 " valid dict: %d v %d\n",
870 end_n - start_n, new_better ?
"better" :
"worse",
871 end_b - start_b, n_rating, b_rating,
872 n_certainty, b_certainty, n_valid_permuter, b_valid_permuter);
880 for (
int i = 0; i < out_words.
size(); ++i)
882 return num_new - num_best;
893 tprintf(
"Trying word using lang %s, oem %d\n",
898 (this->*recognizer)(word_data, in_word, &new_words);
899 if (new_words.
empty()) {
906 for (
int i = 0; i < new_words.
size(); ++i)
907 new_words[i]->DebugTopChoice(
"Lang result");
913 debug, &new_words, best_words);
918 for (
int w = 0; w < words.
size(); ++w) {
919 if (words[w]->tess_failed || !words[w]->tess_accepted)
return false;
928 bool* make_next_word_fuzzy) {
929 *make_next_word_fuzzy =
false;
943 &word_wanted, &overlapped_any_blob,
951 int num_overlapped = 0;
952 int num_overlapped_used = 0;
953 for (
int i = 0; i < overlapped_any_blob.
size(); ++i) {
954 if (overlapped_any_blob[i]) {
956 if (word_wanted[i]) ++num_overlapped_used;
966 int non_overlapped = 0;
967 int non_overlapped_used = 0;
968 for (
int i = 0; i < word_wanted.
size(); ++i) {
969 if (word_wanted[i]) ++non_overlapped_used;
970 if (outlines[i] != NULL) ++non_overlapped_used;
973 tprintf(
"Used %d/%d overlapped %d/%d non-overlaped diacritics on word:",
974 num_overlapped_used, num_overlapped, non_overlapped_used,
980 make_next_word_fuzzy)) {
985 return num_overlapped_used != 0 || non_overlapped_used != 0;
1007 for (blob_it.mark_cycle_pt(); !blob_it.cycled_list(); blob_it.forward()) {
1008 C_BLOB* blob = blob_it.data();
1011 int num_blob_outlines = 0;
1012 for (
int i = 0; i < outlines.
size(); ++i) {
1014 !(*word_wanted)[i]) {
1015 blob_wanted[i] =
true;
1016 (*overlapped_any_blob)[i] =
true;
1017 ++num_blob_outlines;
1021 tprintf(
"%d noise outlines overlap blob at:", num_blob_outlines);
1030 outlines, num_blob_outlines,
1032 for (
int i = 0; i < blob_wanted.
size(); ++i) {
1033 if (blob_wanted[i]) {
1035 (*word_wanted)[i] =
true;
1036 (*target_blobs)[i] = blob;
1054 for (
int i = 0; i < outlines.
size(); ++i) {
1055 if (outlines[i] == NULL)
continue;
1058 int num_blob_outlines = 0;
1059 TBOX total_ol_box(outlines[i]->bounding_box());
1060 while (i < outlines.
size() && outlines[i] != NULL) {
1061 blob_wanted[i] =
true;
1062 total_ol_box += outlines[i]->bounding_box();
1064 ++num_blob_outlines;
1068 while (!blob_it.at_last() &&
1069 blob_it.data_relative(1)->bounding_box().left() <=
1070 total_ol_box.
left()) {
1076 tprintf(
"Num blobless outlines = %d\n", num_blob_outlines);
1077 C_BLOB* left_blob = blob_it.data();
1079 C_BLOB* right_blob = blob_it.at_last() ? NULL : blob_it.data_relative(1);
1080 if ((left_box.
x_overlap(total_ol_box) || right_blob == NULL ||
1083 outlines, num_blob_outlines,
1086 for (
int j = 0; j < blob_wanted.
size(); ++j) {
1087 if (blob_wanted[j]) {
1088 (*word_wanted)[j] =
true;
1089 (*target_blobs)[j] = left_blob;
1092 }
else if (right_blob != NULL &&
1096 right_blob, outlines,
1097 num_blob_outlines, &blob_wanted)) {
1099 for (
int j = 0; j < blob_wanted.
size(); ++j) {
1100 if (blob_wanted[j]) {
1101 (*word_wanted)[j] =
true;
1102 (*target_blobs)[j] = right_blob;
1106 outlines, num_blob_outlines,
1109 for (
int j = 0; j < blob_wanted.
size(); ++j) {
1110 if (blob_wanted[j]) {
1111 (*word_wanted)[j] =
true;
1112 (*target_blobs)[j] = NULL;
1127 float target_cert = certainty_threshold;
1132 tprintf(
"No Noise blob classified as %s=%g(%g) at:", best_str.
string(),
1133 target_cert, target_c2);
1143 pr_it, blob, &all_str);
1146 for (
int i = 0; i < test_outlines.
size(); ++i) {
1147 if (test_outlines[i]) ol_box += outlines[i]->bounding_box();
1149 tprintf(
"All Noise blob classified as %s=%g, delta=%g at:",
1150 all_str.
string(), best_cert, best_cert - target_cert);
1156 while (num_outlines > 1 && best_index >= 0 &&
1157 (blob == NULL || best_cert < target_cert || blob != NULL)) {
1160 for (
int i = 0; i < outlines.
size(); ++i) {
1161 if (test_outlines[i]) {
1162 test_outlines[i] =
false;
1168 for (
int j = 0; j < outlines.
size(); ++j) {
1169 if (test_outlines[j]) ol_box += outlines[j]->bounding_box();
1170 tprintf(
"%d", test_outlines[j]);
1172 tprintf(
" blob classified as %s=%g, delta=%g) at:", str.
string(),
1173 cert, cert - target_cert);
1176 if (cert > best_cert) {
1179 best_outlines = test_outlines;
1181 test_outlines[i] =
true;
1184 if (best_index >= 0) {
1185 test_outlines[best_index] =
false;
1189 if (best_cert >= target_cert) {
1191 *ok_outlines = best_outlines;
1193 tprintf(
"%s noise combination ", blob ?
"Adding" :
"New");
1194 for (
int i = 0; i < best_outlines.
size(); ++i) {
1195 tprintf(
"%d", best_outlines[i]);
1197 tprintf(
" yields certainty %g, beating target of %g\n", best_cert,
1215 ol_it.set_to_list(blob->
out_list());
1216 first_to_keep = ol_it.data();
1218 for (
int i = 0; i < ok_outlines.
size(); ++i) {
1219 if (ok_outlines[i]) {
1222 blob =
new C_BLOB(outlines[i]);
1223 ol_it.set_to_list(blob->
out_list());
1225 ol_it.add_before_stay_put(outlines[i]);
1231 ol_it.move_to_first();
1232 if (first_to_keep == NULL) {
1234 for (; !ol_it.empty(); ol_it.forward()) ol_it.extract();
1239 for (; ol_it.data() != first_to_keep; ol_it.forward()) {
1264 tprintf(
"word xheight=%g, row=%g, range=[%g,%g]\n", word_res->
x_height,
1265 wd.row->x_height(), wd.word->raw_choice->min_x_height(),
1266 wd.word->raw_choice->max_x_height());
1268 float cert = wd.word->raw_choice->certainty();
1269 float rat = wd.word->raw_choice->rating();
1270 *c2 = rat > 0.0f ? cert * cert / rat : 0.0f;
1271 *best_str = wd.word->raw_choice->unichar_string();
1293 clock_t start_t = clock();
1296 tprintf(
"%s word with lang %s at:",
1297 word->
done ?
"Already done" :
"Processing",
1307 int sub = sub_langs_.size();
1308 if (most_recently_used_ !=
this) {
1310 for (sub = 0; sub < sub_langs_.size() &&
1311 most_recently_used_ != sub_langs_[sub]; ++sub) {}
1314 *word_data, recognizer, debug, &word_data->
lang_words[sub], &best_words);
1315 Tesseract* best_lang_tess = most_recently_used_;
1316 if (!WordsAcceptable(best_words)) {
1318 if (most_recently_used_ !=
this &&
1322 best_lang_tess =
this;
1324 for (
int i = 0; !WordsAcceptable(best_words) && i < sub_langs_.size();
1326 if (most_recently_used_ != sub_langs_[i] &&
1330 best_lang_tess = sub_langs_[i];
1334 most_recently_used_ = best_lang_tess;
1335 if (!best_words.
empty()) {
1336 if (best_words.
size() == 1 && !best_words[0]->combination) {
1341 word_data->
word = best_words.
back();
1348 clock_t ocr_t = clock();
1350 tprintf(
"%s (ocr took %.2f sec)\n",
1352 static_cast<double>(ocr_t-start_t)/CLOCKS_PER_SEC);
1365 ROW* row = word_data.
row;
1369 #ifndef ANDROID_BUILD 1374 if (!out_words->
empty())
1415 tprintf(
"New XHT Match:%s = %s ",
1426 new_x_ht > 0.1 ?
"STILL DOUBT" :
"OK",
1427 accept_new_word ?
"ACCEPTED" :
"");
1436 if (original_misfits == 0)
1438 float baseline_shift = 0.0f;
1440 if (baseline_shift != 0.0f) {
1446 if (original_misfits > 0) {
1447 float new_baseline_shift;
1469 float baseline_shift,
float new_x_ht,
1471 bool accept_new_x_ht =
false;
1488 tprintf(
"Old misfits=%d with x-height %f, new=%d with x-height %f\n",
1490 new_misfits, new_x_ht);
1491 tprintf(
"Old rating= %f, certainty=%f, new=%f, %f\n",
1497 accept_new_x_ht = new_misfits < original_misfits &&
1506 if (accept_new_x_ht) {
1526 ROW* row = word_data.
row;
1553 #ifndef GRAPHICS_DISABLED 1588 tprintf(
"POST FIX_QUOTES FAIL String:\"%s\"; Strlen=%d;" 1615 if (choice != NULL) {
1616 if (best_choice == NULL || choice->
rating() < best_choice->
rating())
1617 best_choice = choice;
1626 static void CorrectRepcharChoices(
BLOB_CHOICE* blob_choice,
1632 if (choice == NULL) {
1634 choice_it.add_before_stay_put(
new BLOB_CHOICE(*blob_choice));
1638 for (
int i = 0; i < word->
length(); ++i) {
1657 for (
int i = 0; i < word.
length(); ++i) {
1663 int max_count = rep_ch.MaxCount(&maxch_id);
1665 BLOB_CHOICE* best_choice = FindBestMatchingChoice(maxch_id, word_res);
1666 if (best_choice == NULL) {
1667 tprintf(
"Failed to find a choice for %s, occurring %d times\n",
1677 C_BLOB* prev_blob = blob_it.data();
1678 for (blob_it.forward(); !blob_it.at_first(); blob_it.forward()) {
1679 C_BLOB* blob = blob_it.data();
1681 gap -= prev_blob->bounding_box().right();
1686 CorrectRepcharChoices(best_choice, word_res);
1691 const UNICHARSET& char_set,
const char *s,
const char *lengths) {
1694 int leading_punct_count;
1695 int upper_count = 0;
1696 int hyphen_pos = -1;
1699 if (strlen (lengths) > 20)
1705 offset += lengths[i++];
1706 leading_punct_count = i;
1709 while (s[offset] !=
'\0' && char_set.
get_isupper(s + offset, lengths[i])) {
1710 offset += lengths[i++];
1713 if (upper_count > 1) {
1717 while (s[offset] !=
'\0' && char_set.
get_islower(s + offset, lengths[i])) {
1718 offset += lengths[i++];
1726 if (lengths[i] == 1 && s[offset] ==
'-') {
1728 offset += lengths[i++];
1729 if (s[offset] !=
'\0') {
1730 while ((s[offset] !=
'\0') &&
1732 offset += lengths[i++];
1734 if (i < hyphen_pos + 3)
1739 if (lengths[i] == 1 && (s[offset] ==
'\'') &&
1740 lengths[i + 1] == 1 && (s[offset + lengths[i]] ==
's')) {
1741 offset += lengths[i++];
1742 offset += lengths[i++];
1745 if (upper_count > 0)
1752 if (lengths[i] == 1 && s[offset] !=
'\0' &&
1754 offset += lengths[i++];
1755 if (lengths[i] == 1 && s[offset] !=
'\0' && i > 0 &&
1756 s[offset - lengths[i - 1]] != s[offset] &&
1758 offset += lengths[i++];
1760 if (s[offset] !=
'\0')
1769 if (s[0] !=
'\0' && char_set.
get_isupper(s, lengths[0])) {
1771 while (s[offset] !=
'\0' &&
1773 lengths[i + 1] == 1 && s[offset + lengths[i]] ==
'.') {
1774 offset += lengths[i++];
1775 offset += lengths[i++];
1778 else if (s[0] !=
'\0' && char_set.
get_islower(s, lengths[0])) {
1780 while (s[offset] !=
'\0' &&
1782 lengths[i + 1] == 1 && s[offset + lengths[i]] ==
'.') {
1783 offset += lengths[i++];
1784 offset += lengths[i++];
1787 if (s[offset] !=
'\0')
1812 tprintf (
"classify_word_pass1 start\n");
1816 tprintf (
"make_reject_map: initial map");
1819 tprintf (
"make_reject_map: after NN");
1822 tprintf (
"classify_word_pass2 - START");
1825 tprintf (
"classify_word_pass2 - Pre Xht");
1828 tprintf (
"classify_word_pass2 - END");
1829 show_map_detail =
TRUE;
1841 tprintf (
"After Poor quality rejection");
1844 tprintf (
"unrej_good_quality_words - START");
1847 tprintf (
"unrej_good_quality_words - END");
1850 tprintf (
"Write results pass");
1851 show_map_detail =
TRUE;
1858 if (show_map_detail) {
1866 tprintf(
"null best choice\n");
1869 tprintf (
"Done flag: %s\n\n", word->
done ?
"TRUE" :
"FALSE");
1881 static void find_modal_font(
1894 fonts->
add (font, -*font_count);
1914 if (fontinfo_size == 0)
return;
1922 tprintf(
"Examining fonts in %s\n",
1927 if (choice == NULL)
continue;
1929 for (
int f = 0; f < fonts.
size(); ++f) {
1930 int fontinfo_id = fonts[f].fontinfo_id;
1931 if (0 <= fontinfo_id && fontinfo_id < fontinfo_size) {
1932 font_total_score[fontinfo_id] += fonts[f].score;
1937 int score1 = 0, score2 = 0;
1938 inT16 font_id1 = -1, font_id2 = -1;
1939 for (
int f = 0; f < fontinfo_size; ++f) {
1941 tprintf(
"Font %s, total score = %d\n",
1944 if (font_total_score[f] > score1) {
1946 font_id2 = font_id1;
1947 score1 = font_total_score[f];
1949 }
else if (font_total_score[f] > score2) {
1950 score2 = font_total_score[f];
1964 tprintf(
"Word modal font=%s, score=%d, 2nd choice %s/%d\n",
1969 tprintf(
"Word modal font=%s, score=%d. No 2nd choice\n",
1988 STATS doc_fonts(0, font_table_size_);
1993 word = page_res_it.
word();
2002 int8_t doc_font_count;
2003 find_modal_font(&doc_fonts, &doc_font, &doc_font_count);
2004 if (doc_font_count == 0)
2010 word = page_res_it.
word();
2025 word = page_res_it.
word();
2029 if (!(count == length || (length > 3 && count >= length * 3 / 4))) {
2046 if (word->best_choices.singleton())
2050 if (word->tesseract->getDict().valid_word(*best) != 0)
2053 WERD_CHOICE_IT choice_it(&word->best_choices);
2054 for (choice_it.mark_cycle_pt(); !choice_it.cycled_list();
2055 choice_it.forward()) {
2057 if (word->tesseract->getDict().valid_word(*alternate)) {
2060 tprintf(
"Dictionary correction replaces best choice '%s' with '%s'\n",
2065 word->ReplaceBestChoice(alternate);
bool poly_allow_detailed_fx
double noise_cert_disjoint
void add_str_int(const char *str, int number)
bool tessedit_enable_dict_correction
bool deadline_exceeded() const
void InitForRetryRecognition(const WERD_RES &source)
bool tessedit_fix_hyphens
void CopyTruth(const BlamerBundle &other)
C_OUTLINE_LIST * out_list()
void classify_word_pass1(const WordData &word_data, WERD_RES **in_word, PointerVector< WERD_RES > *out_words)
void ReplaceBestChoice(WERD_CHOICE *choice)
void output_pass(PAGE_RES_IT &page_res_it, const TBOX *target_word_box)
#define LOC_WRITE_RESULTS
bool RecogAllWordsPassN(int pass_n, ETEXT_DESC *monitor, PAGE_RES_IT *pr_it, GenericVector< WordData > *words)
bool TestNewNormalization(int original_misfits, float baseline_shift, float new_x_ht, WERD_RES *word, BLOCK *block, ROW *row)
const GenericVector< tesseract::ScoredFont > & fonts() const
UNICHAR_ID unichar_id(int index) const
float max_x_height() const
volatile inT8 ocr_alive
true if not last
bool classify_bln_numeric_mode
void plot(ScrollView *window)
float min_x_height() const
void init_to_size(int size, T t)
void fix_fuzzy_spaces(ETEXT_DESC *monitor, inT32 word_count, PAGE_RES *page_res)
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)
static const double kXHeightCapRatio
const char *const kBackUpConfigFile
void set_global_loc_code(int loc_code)
const FontInfo * fontinfo2
WERD_CHOICE * best_choice
void classify_word_and_language(int pass_n, PAGE_RES_IT *pr_it, WordData *word_data)
void SetScriptPositions()
void CleanupSingleRowResult(PageSegMode pageseg_mode, PAGE_RES *page_res)
int multilang_debug_level
BlamerBundle * blamer_bundle
static bool valid_word_permuter(uinT8 perm, bool numbers_ok)
Check all the DAWGs to see if this word is in any of them.
bool tessedit_minimal_rejection
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 font_recognition_pass(PAGE_RES *page_res)
bool x_overlap(const TBOX &box) const
void script_pos_pass(PAGE_RES *page_res)
float ComputeCompatibleXheight(WERD_RES *word_res, float *baseline_shift)
void ReplaceCurrentWord(tesseract::PointerVector< WERD_RES > *words)
bool tessedit_debug_quality_metrics
double noise_cert_basechar
const double kMinRefitXHeightFraction
const UNICHARSET & GetUnicharset() const
const STRING debug_string() const
bool tessedit_fix_fuzzy_spaces
BOOL8 check_debug_pt(WERD_RES *word, int location)
void quality_based_rejection(PAGE_RES_IT &page_res_it, BOOL8 good_quality_doc)
int tessedit_ocr_engine_mode
bool AdaptableWord(WERD_RES *word)
void LSTMRecognizeWord(const BLOCK &block, ROW *row, WERD_RES *word, PointerVector< WERD_RES > *words)
void BestChoiceToCorrectText()
const char * string() const
int tessedit_pageseg_mode
void * cancel_this
called whenever progress increases
bool ReassignDiacritics(int pass, PAGE_RES_IT *pr_it, bool *make_next_word_fuzzy)
bool AdaptiveClassifierIsFull() const
bool TrainedXheightFix(WERD_RES *word, BLOCK *block, ROW *row)
const STRING & misadaption_debug() const
UnicityTable< FontInfo > & get_fontinfo_table()
bool textord_use_cjk_fp_model
bool major_x_overlap(const TBOX &box) const
inT16 word_blob_quality(WERD_RES *word, ROW *row)
void ReportXhtFixResult(bool accept_new_word, float new_x_ht, WERD_RES *word, WERD_RES *new_word)
inT32 pile_count(inT32 value) const
TBOX bounding_box() const
tesseract::Tesseract * tesseract
tesseract::BoxWord * box_word
int quality_min_initial_alphas_reqd
void set_word_fonts(WERD_RES *word)
BOOL8 flag(WERD_FLAGS mask) const
IncorrectResultReason incorrect_result_reason() const
WERD_RES * restart_page()
int tessedit_tess_adaption_mode
void bigram_correction_pass(PAGE_RES *page_res)
double quality_outline_pc
bool valid_bigram(const WERD_CHOICE &word1, const WERD_CHOICE &word2) const
bool tessedit_rejection_debug
void dictionary_correction_pass(PAGE_RES *page_res)
static int SortByXMiddle(const void *v1, const void *v2)
static C_BLOB * deep_copy(const C_BLOB *src)
PROGRESS_FUNC progress_callback
returns true to cancel
bool AdaptiveClassifierIsEmpty() const
void classify_word_pass2(const WordData &word_data, WERD_RES **in_word, PointerVector< WERD_RES > *out_words)
void blamer_pass(PAGE_RES *page_res)
bool tessedit_timing_debug
inT32 x_height() const
return xheight
bool tessedit_enable_bigram_correction
int tessedit_bigram_debug
bool tessedit_word_for_word
PAGE_RES_IT * make_pseudo_word(PAGE_RES *page_res, const TBOX &selection_box)
bool tessedit_debug_fonts
BOOL8 recog_interactive(PAGE_RES_IT *pr_it)
WERD_CHOICE_LIST best_choices
void Add(T value, int count)
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)
void set_global_subloc_code(int loc_code)
const FontInfo * fontinfo
BOOL8 contains(const char c) const
bool tess_acceptable_word(WERD_RES *word)
void GetNonSuperscriptSpan(int *start, int *end) const
char * chs_trailing_punct2
T ClipToRange(const T &x, const T &lower_bound, const T &upper_bound)
int RetryWithLanguage(const WordData &word_data, WordRecognizer recognizer, bool debug, WERD_RES **in_word, PointerVector< WERD_RES > *best_words)
void rejection_passes(PAGE_RES *page_res, ETEXT_DESC *monitor, const TBOX *target_word_box, const char *word_config)
char * chs_trailing_punct1
void StartBackupAdaptiveClassifier()
void ZoomToRectangle(int x1, int y1, int x2, int y2)
static bool ReadParamsFile(const char *file, SetParamConstraint constraint, ParamsVectors *member_params)
bool tessedit_display_outwords
inT16 doc_good_char_quality
int CountMisfitTops(WERD_RES *word_res)
EXTERN ScrollView * fx_win
bool contains(const FCOORD pt) const
float ClassifyBlobAsWord(int pass_n, PAGE_RES_IT *pr_it, C_BLOB *blob, STRING *best_str, float *c2)
bool major_overlap(const TBOX &box) const
WERD_CHOICE shallow_copy(int start, int end) const
CANCEL_FUNC cancel
for errcode use
void word_char_quality(WERD_RES *word, ROW *row, inT16 *match_count, inT16 *accepted_match_count)
static void LastChanceBlame(bool debug, WERD_RES *word)
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 add(inT32 value, inT32 count)
bool EqualIgnoringCaseAndTerminalPunct(const WERD_CHOICE &word1, const WERD_CHOICE &word2)
void GetNoiseOutlines(GenericVector< C_OUTLINE *> *outlines)
void rej_word_bad_quality()
void tess_add_doc_word(WERD_CHOICE *word_choice)
void set_unichar_id(UNICHAR_ID unichar_id, int index)
void fix_rep_char(PAGE_RES_IT *page_res_it)
void SetupAllWordsPassN(int pass_n, const TBOX *target_word_box, const char *word_config, PAGE_RES *page_res, GenericVector< WordData > *words)
const STRING & unichar_string() const
void SwitchAdaptiveClassifier()
bool AddSelectedOutlines(const GenericVector< bool > &wanted, const GenericVector< C_BLOB *> &target_blobs, const GenericVector< C_OUTLINE *> &outlines, bool *make_next_word_fuzzy)
POLY_BLOCK * poly_block() const
inT16 word_outline_errs(WERD_RES *word)
ACCEPTABLE_WERD_TYPE acceptable_word_string(const UNICHARSET &char_set, const char *s, const char *lengths)
TBOX bounding_box() const
void full_print(FILE *fp)
C_BLOB_LIST * cblob_list()
bool tessedit_enable_doc_dict
double classify_max_rating_ratio
void match_word_pass_n(int pass_n, WERD_RES *word, ROW *row, BLOCK *block)
void PrintBestChoices() const
BLOB_CHOICE * GetBlobChoice(int index) const
PointerVector< WERD_RES > lang_words
bool tessedit_dump_choices
void tess_segment_pass_n(int pass_n, WERD_RES *word)
BLOB_CHOICE_LIST * GetBlobChoices(int index) const
bool tessedit_minimal_rej_pass1
UNICHAR_ID unichar_id() const
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)
C_BLOB_LIST * rej_cblob_list()
void ConsumeWordResults(WERD_RES *word)
void SetupWordPassN(int pass_n, WordData *word)
void recog_pseudo_word(PAGE_RES *page_res, TBOX &selection_box)
void(Tesseract::* WordRecognizer)(const WordData &word_data, WERD_RES **in_word, PointerVector< WERD_RES > *out_words)
bool get_isupper(UNICHAR_ID unichar_id) const
WERD_RES * InsertSimpleCloneWord(const WERD_RES &clone_res, WERD *new_word)
BLOB_CHOICE * FindMatchingChoice(UNICHAR_ID char_id, BLOB_CHOICE_LIST *bc_list)
bool wordrec_debug_blamer
const UNICHARSET * uch_set
bool get_islower(UNICHAR_ID unichar_id) const
static const char * IncorrectReasonName(IncorrectResultReason irr)
double classify_max_certainty_margin
inT16 progress
chars in this buffer(0)
void LearnWord(const char *fontname, WERD_RES *word)
bool tessedit_reject_bad_qual_wds
void initialise(inT16 length)
bool right_to_left() const
UnicityTable< FontInfo > fontinfo_table_
bool SubAndSuperscriptFix(WERD_RES *word_res)
bool recog_all_words(PAGE_RES *page_res, ETEXT_DESC *monitor, const TBOX *target_word_box, const char *word_config, int dopasses)
bool top_bottom_useful() const
GenericVector< STRING > misadaption_log
void SetMisAdaptionDebug(const WERD_CHOICE *best_choice, bool debug)
GenericVector< int > blame_reasons
static void PrintParams(FILE *fp, const ParamsVectors *member_params)
WERD * ConstructFromSingleBlob(bool bol, bool eol, C_BLOB *blob)
void MakeCurrentWordFuzzy()
FCOORD classify_rotation() const
bool ProcessTargetWord(const TBOX &word_box, const TBOX &target_word_box, const char *word_config, int pass)
bool script_has_xheight() const
TBOX bounding_box() const
void PrerecAllWordsPar(const GenericVector< WordData > &words)
STRING debug_str(UNICHAR_ID id) const
BLOCK_RES * block() const
void make_reject_map(WERD_RES *word, ROW *row, inT16 pass)
BOOL8 word_adaptable(WERD_RES *word, uinT16 mode)
WERD_CHOICE * prev_word_best_choice_
bool tessedit_test_adaption