50 #define MIN_FONT_ROW_COUNT 8 51 #define MAX_XHEIGHT_DIFF 3 67 TBOX &selection_box) {
91 tprintf(
"\n%d chars; word_blob_quality: %d; outline_errs: %d; " 92 "char_quality: %d; good_char_quality: %d\n",
116 const TBOX& target_word_box,
117 const char* word_config,
119 if (word_config != NULL) {
121 if (backup_config_file_ == NULL) {
123 FILE* config_fp = fopen(backup_config_file_,
"wb");
131 if (backup_config_file_ != NULL) {
135 backup_config_file_ = NULL;
138 }
else if (pass > 1 && !word_box.
major_overlap(target_word_box)) {
146 const TBOX* target_word_box,
147 const char* word_config,
154 if (target_word_box == NULL ||
156 *target_word_box, word_config, 1)) {
161 for (
int w = 0; w < words->
size(); ++w) {
163 if (w > 0) (*words)[w].prev_word = &(*words)[w - 1];
169 if (pass_n == 1 || !word->
word->
done) {
177 }
else if (pass_n == 2) {
184 for (
int s = 0; s <= sub_langs_.size(); ++s) {
186 Tesseract* lang_t = s < sub_langs_.size() ? sub_langs_[s] :
this;
213 for (
int w = 0; w < words->
size(); ++w) {
215 if (w > 0) word->
prev_word = &(*words)[w - 1];
216 if (monitor != NULL) {
235 for (; w < words->
size(); ++w) {
249 while (pr_it->
word() != NULL && pr_it->
word() != word->
word)
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 NO_CUBE_BUILD 442 if (monitor != NULL) {
455 while (word_it.
forward() != 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.
empty()) {
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,
791 PointerVector<WERD_RES>* new_words,
792 PointerVector<WERD_RES>* best_words) {
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)
868 best_words->push_back(out_words[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 NO_CUBE_BUILD 1389 tprintf(
"New XHT Match:%s = %s ",
1400 new_x_ht > 0.1 ?
"STILL DOUBT" :
"OK",
1401 accept_new_word ?
"ACCEPTED" :
"");
1410 if (original_misfits == 0)
1412 float baseline_shift = 0.0f;
1414 if (baseline_shift != 0.0f) {
1420 if (original_misfits > 0) {
1421 float new_baseline_shift;
1443 float baseline_shift,
float new_x_ht,
1445 bool accept_new_x_ht =
false;
1462 tprintf(
"Old misfits=%d with x-height %f, new=%d with x-height %f\n",
1464 new_misfits, new_x_ht);
1465 tprintf(
"Old rating= %f, certainty=%f, new=%f, %f\n",
1471 accept_new_x_ht = new_misfits < original_misfits &&
1480 if (accept_new_x_ht) {
1504 ROW* row = word_data.
row;
1531 #ifndef GRAPHICS_DISABLED 1566 tprintf(
"POST FIX_QUOTES FAIL String:\"%s\"; Strlen=%d;" 1593 if (choice != NULL) {
1594 if (best_choice == NULL || choice->
rating() < best_choice->
rating())
1595 best_choice = choice;
1604 static void CorrectRepcharChoices(
BLOB_CHOICE* blob_choice,
1610 if (choice == NULL) {
1612 choice_it.add_before_stay_put(
new BLOB_CHOICE(*blob_choice));
1616 for (
int i = 0; i < word->
length(); ++i) {
1635 for (
int i = 0; i < word.
length(); ++i) {
1641 int max_count = rep_ch.MaxCount(&maxch_id);
1643 BLOB_CHOICE* best_choice = FindBestMatchingChoice(maxch_id, word_res);
1644 if (best_choice == NULL) {
1645 tprintf(
"Failed to find a choice for %s, occurring %d times\n",
1655 C_BLOB* prev_blob = blob_it.data();
1656 for (blob_it.forward(); !blob_it.at_first(); blob_it.forward()) {
1657 C_BLOB* blob = blob_it.data();
1659 gap -= prev_blob->bounding_box().right();
1664 CorrectRepcharChoices(best_choice, word_res);
1669 const UNICHARSET& char_set,
const char *s,
const char *lengths) {
1672 int leading_punct_count;
1673 int upper_count = 0;
1674 int hyphen_pos = -1;
1677 if (strlen (lengths) > 20)
1683 offset += lengths[i++];
1684 leading_punct_count = i;
1687 while (s[offset] !=
'\0' && char_set.
get_isupper(s + offset, lengths[i])) {
1688 offset += lengths[i++];
1691 if (upper_count > 1) {
1695 while (s[offset] !=
'\0' && char_set.
get_islower(s + offset, lengths[i])) {
1696 offset += lengths[i++];
1704 if (lengths[i] == 1 && s[offset] ==
'-') {
1706 offset += lengths[i++];
1707 if (s[offset] !=
'\0') {
1708 while ((s[offset] !=
'\0') &&
1710 offset += lengths[i++];
1712 if (i < hyphen_pos + 3)
1717 if (lengths[i] == 1 && (s[offset] ==
'\'') &&
1718 lengths[i + 1] == 1 && (s[offset + lengths[i]] ==
's')) {
1719 offset += lengths[i++];
1720 offset += lengths[i++];
1723 if (upper_count > 0)
1730 if (lengths[i] == 1 && s[offset] !=
'\0' &&
1732 offset += lengths[i++];
1733 if (lengths[i] == 1 && s[offset] !=
'\0' && i > 0 &&
1734 s[offset - lengths[i - 1]] != s[offset] &&
1736 offset += lengths[i++];
1738 if (s[offset] !=
'\0')
1747 if (s[0] !=
'\0' && char_set.
get_isupper(s, lengths[0])) {
1749 while (s[offset] !=
'\0' &&
1751 lengths[i + 1] == 1 && s[offset + lengths[i]] ==
'.') {
1752 offset += lengths[i++];
1753 offset += lengths[i++];
1756 else if (s[0] !=
'\0' && char_set.
get_islower(s, lengths[0])) {
1758 while (s[offset] !=
'\0' &&
1760 lengths[i + 1] == 1 && s[offset + lengths[i]] ==
'.') {
1761 offset += lengths[i++];
1762 offset += lengths[i++];
1765 if (s[offset] !=
'\0')
1790 tprintf (
"classify_word_pass1 start\n");
1794 tprintf (
"make_reject_map: initial map");
1797 tprintf (
"make_reject_map: after NN");
1800 tprintf (
"classify_word_pass2 - START");
1803 tprintf (
"classify_word_pass2 - Pre Xht");
1806 tprintf (
"classify_word_pass2 - END");
1807 show_map_detail =
TRUE;
1819 tprintf (
"After Poor quality rejection");
1822 tprintf (
"unrej_good_quality_words - START");
1825 tprintf (
"unrej_good_quality_words - END");
1828 tprintf (
"Write results pass");
1829 show_map_detail =
TRUE;
1836 if (show_map_detail) {
1844 tprintf(
"null best choice\n");
1847 tprintf (
"Done flag: %s\n\n", word->
done ?
"TRUE" :
"FALSE");
1859 static void find_modal_font(
1872 fonts->
add (font, -*font_count);
1892 if (fontinfo_size == 0)
return;
1900 tprintf(
"Examining fonts in %s\n",
1905 if (choice == NULL)
continue;
1907 for (
int f = 0; f < fonts.
size(); ++f) {
1908 int fontinfo_id = fonts[f].fontinfo_id;
1909 if (0 <= fontinfo_id && fontinfo_id < fontinfo_size) {
1910 font_total_score[fontinfo_id] += fonts[f].score;
1915 int score1 = 0, score2 = 0;
1916 inT16 font_id1 = -1, font_id2 = -1;
1917 for (
int f = 0; f < fontinfo_size; ++f) {
1919 tprintf(
"Font %s, total score = %d\n",
1922 if (font_total_score[f] > score1) {
1924 font_id2 = font_id1;
1925 score1 = font_total_score[f];
1927 }
else if (font_total_score[f] > score2) {
1928 score2 = font_total_score[f];
1942 tprintf(
"Word modal font=%s, score=%d, 2nd choice %s/%d\n",
1947 tprintf(
"Word modal font=%s, score=%d. No 2nd choice\n",
1966 STATS doc_fonts(0, font_table_size_);
1971 word = page_res_it.
word();
1980 inT8 doc_font_count;
1981 find_modal_font(&doc_fonts, &doc_font, &doc_font_count);
1982 if (doc_font_count == 0)
1988 word = page_res_it.
word();
2003 word = page_res_it.
word();
2007 if (!(
count == length || (length > 3 &&
count >= length * 3 / 4))) {
2024 if (word->best_choices.singleton())
2028 if (word->tesseract->getDict().valid_word(*best) != 0)
2031 WERD_CHOICE_IT choice_it(&word->best_choices);
2032 for (choice_it.mark_cycle_pt(); !choice_it.cycled_list();
2033 choice_it.forward()) {
2035 if (word->tesseract->getDict().valid_word(*alternate)) {
2038 tprintf(
"Dictionary correction replaces best choice '%s' with '%s'\n",
2043 word->ReplaceBestChoice(alternate);
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(Tesseract::* WordRecognizer)(const WordData &word_data, WERD_RES **in_word, PointerVector< WERD_RES > *out_words)
PROGRESS_FUNC progress_callback
returns true to cancel
void set_word_fonts(WERD_RES *word)
void tess_add_doc_word(WERD_CHOICE *word_choice)
void script_pos_pass(PAGE_RES *page_res)
const STRING & misadaption_debug() const
void SetupAllWordsPassN(int pass_n, const TBOX *target_word_box, const char *word_config, PAGE_RES *page_res, GenericVector< WordData > *words)
void rej_word_bad_quality()
void PrintBestChoices() const
bool tessedit_reject_bad_qual_wds
CANCEL_FUNC cancel
for errcode use
bool right_to_left() const
bool tessedit_fix_fuzzy_spaces
int tessedit_ocr_engine_mode
void StartBackupAdaptiveClassifier()
void classify_word_pass2(const WordData &word_data, WERD_RES **in_word, PointerVector< WERD_RES > *out_words)
int tessedit_pageseg_mode
void match_word_pass_n(int pass_n, WERD_RES *word, ROW *row, BLOCK *block)
WERD_RES * InsertSimpleCloneWord(const WERD_RES &clone_res, WERD *new_word)
void blamer_pass(PAGE_RES *page_res)
const double kMinRefitXHeightFraction
bool top_bottom_useful() const
bool ReassignDiacritics(int pass, PAGE_RES_IT *pr_it, bool *make_next_word_fuzzy)
BLOB_CHOICE * FindMatchingChoice(UNICHAR_ID char_id, BLOB_CHOICE_LIST *bc_list)
bool TrainedXheightFix(WERD_RES *word, BLOCK *block, ROW *row)
bool tessedit_debug_fonts
const STRING & unichar_string() const
UNICHAR_ID unichar_id(int index) const
bool tess_acceptable_word(WERD_RES *word)
void full_print(FILE *fp)
static int SortByXMiddle(const void *v1, const void *v2)
void initialise(inT16 length)
bool poly_allow_detailed_fx
bool EqualIgnoringCaseAndTerminalPunct(const WERD_CHOICE &word1, const WERD_CHOICE &word2)
const FontInfo * fontinfo2
void set_unichar_id(UNICHAR_ID unichar_id, int index)
bool tessedit_enable_dict_correction
void ConsumeWordResults(WERD_RES *word)
void add(inT32 value, inT32 count)
void set_global_loc_code(int loc_code)
TBOX bounding_box() const
const GenericVector< tesseract::ScoredFont > & fonts() const
bool SubAndSuperscriptFix(WERD_RES *word_res)
void ReplaceBestChoice(WERD_CHOICE *choice)
void fix_rep_char(PAGE_RES_IT *page_res_it)
T ClipToRange(const T &x, const T &lower_bound, const T &upper_bound)
bool ProcessTargetWord(const TBOX &word_box, const TBOX &target_word_box, const char *word_config, int pass)
void LearnWord(const char *fontname, WERD_RES *word)
C_OUTLINE_LIST * out_list()
bool tessedit_enable_bigram_correction
bool tessedit_word_for_word
inT16 word_outline_errs(WERD_RES *word)
BOOL8 recog_interactive(PAGE_RES_IT *pr_it)
ACCEPTABLE_WERD_TYPE acceptable_word_string(const UNICHARSET &char_set, const char *s, const char *lengths)
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)
WERD_CHOICE shallow_copy(int start, int end) const
WERD_RES * restart_page()
bool tessedit_minimal_rejection
WERD_CHOICE * best_choice
bool tessedit_enable_doc_dict
bool tessedit_dump_choices
void run_cube_combiner(PAGE_RES *page_res)
void tess_segment_pass_n(int pass_n, WERD_RES *word)
char * chs_trailing_punct1
double noise_cert_disjoint
void SetScriptPositions()
UNICHAR_ID unichar_id() const
void add_str_int(const char *str, int number)
inT16 progress
chars in this buffer(0)
UnicityTable< FontInfo > fontinfo_table_
bool tessedit_fix_hyphens
GenericVector< int > blame_reasons
void classify_word_pass1(const WordData &word_data, WERD_RES **in_word, PointerVector< WERD_RES > *out_words)
void cube_word_pass1(BLOCK *block, ROW *row, WERD_RES *word)
IncorrectResultReason incorrect_result_reason() const
void set_global_subloc_code(int loc_code)
bool major_x_overlap(const TBOX &box) const
void CleanupSingleRowResult(PageSegMode pageseg_mode, PAGE_RES *page_res)
void recog_pseudo_word(PAGE_RES *page_res, TBOX &selection_box)
void * cancel_this
called whenever progress increases
tesseract::BoxWord * box_word
const char * string() const
bool x_overlap(const TBOX &box) const
GenericVector< STRING > misadaption_log
const FontInfo * fontinfo
volatile inT8 ocr_alive
true if not last
void plot(ScrollView *window)
static const char * IncorrectReasonName(IncorrectResultReason irr)
bool contains(const FCOORD pt) const
void ReplaceCurrentWord(tesseract::PointerVector< WERD_RES > *words)
BOOL8 flag(WERD_FLAGS mask) const
void fix_fuzzy_spaces(ETEXT_DESC *monitor, inT32 word_count, PAGE_RES *page_res)
static const double kXHeightCapRatio
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)
#define LOC_WRITE_RESULTS
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)
PAGE_RES_IT * make_pseudo_word(PAGE_RES *page_res, const TBOX &selection_box)
BlamerBundle * blamer_bundle
bool get_isupper(UNICHAR_ID unichar_id) const
inT16 doc_good_char_quality
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 font_recognition_pass(PAGE_RES *page_res)
bool deadline_exceeded() const
int quality_min_initial_alphas_reqd
bool AdaptiveClassifierIsEmpty() const
STRING debug_str(UNICHAR_ID id) const
int RetryWithLanguage(const WordData &word_data, WordRecognizer recognizer, WERD_RES **in_word, PointerVector< WERD_RES > *best_words)
TBOX bounding_box() const
float min_x_height() const
BOOL8 word_adaptable(WERD_RES *word, uinT16 mode)
void MakeCurrentWordFuzzy()
void bigram_correction_pass(PAGE_RES *page_res)
bool tessedit_debug_quality_metrics
double noise_cert_basechar
bool tessedit_rejection_debug
BLOB_CHOICE * GetBlobChoice(int index) const
void dictionary_correction_pass(PAGE_RES *page_res)
void Add(T value, int count)
bool tessedit_test_adaption
BLOB_CHOICE_LIST * GetBlobChoices(int index) const
void quality_based_rejection(PAGE_RES_IT &page_res_it, BOOL8 good_quality_doc)
BLOCK_RES * block() 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.
void InitForRetryRecognition(const WERD_RES &source)
void SetupWordPassN(int pass_n, WordData *word)
WERD_CHOICE_LIST best_choices
PointerVector< WERD_RES > lang_words
void SetMisAdaptionDebug(const WERD_CHOICE *best_choice, bool debug)
const char *const kBackUpConfigFile
int tessedit_bigram_debug
EXTERN ScrollView * fx_win
bool wordrec_debug_blamer
void output_pass(PAGE_RES_IT &page_res_it, const TBOX *target_word_box)
bool RecogAllWordsPassN(int pass_n, ETEXT_DESC *monitor, PAGE_RES_IT *pr_it, GenericVector< WordData > *words)
double classify_max_certainty_margin
void GetNoiseOutlines(GenericVector< C_OUTLINE *> *outlines)
inT16 word_blob_quality(WERD_RES *word, ROW *row)
const UNICHARSET * uch_set
void ReportXhtFixResult(bool accept_new_word, float new_x_ht, WERD_RES *word, WERD_RES *new_word)
BOOL8 contains(const char c) const
static C_BLOB * deep_copy(const C_BLOB *src)
char * chs_trailing_punct2
bool recog_all_words(PAGE_RES *page_res, ETEXT_DESC *monitor, const TBOX *target_word_box, const char *word_config, int dopasses)
inT32 pile_count(inT32 value) const
bool AddSelectedOutlines(const GenericVector< bool > &wanted, const GenericVector< C_BLOB *> &target_blobs, const GenericVector< C_OUTLINE *> &outlines, bool *make_next_word_fuzzy)
static bool TESS_API ReadParamsFile(const char *file, SetParamConstraint constraint, ParamsVectors *member_params)
WERD_CHOICE * prev_word_best_choice_
int CountMisfitTops(WERD_RES *word_res)
float max_x_height() const
tesseract::Tesseract * tesseract
float ClassifyBlobAsWord(int pass_n, PAGE_RES_IT *pr_it, C_BLOB *blob, STRING *best_str, float *c2)
void CopyTruth(const BlamerBundle &other)
FCOORD classify_rotation() const
void PrerecAllWordsPar(const GenericVector< WordData > &words)
void make_reject_map(WERD_RES *word, ROW *row, inT16 pass)
void classify_word_and_language(int pass_n, PAGE_RES_IT *pr_it, WordData *word_data)
bool AdaptiveClassifierIsFull() const
static void LastChanceBlame(bool debug, WERD_RES *word)
void word_char_quality(WERD_RES *word, ROW *row, inT16 *match_count, inT16 *accepted_match_count)
int tessedit_tess_adaption_mode
bool major_overlap(const TBOX &box) const
void GetNonSuperscriptSpan(int *start, int *end) const
double quality_outline_pc
inT32 x_height() const
return xheight
bool classify_bln_numeric_mode
bool script_has_xheight() const
double classify_max_rating_ratio
bool get_islower(UNICHAR_ID unichar_id) const
UnicityTable< FontInfo > & get_fontinfo_table()
float ComputeCompatibleXheight(WERD_RES *word_res, float *baseline_shift)
static void PrintParams(FILE *fp, const ParamsVectors *member_params)
bool tessedit_timing_debug
BOOL8 check_debug_pt(WERD_RES *word, int location)
bool TestNewNormalization(int original_misfits, float baseline_shift, float new_x_ht, WERD_RES *word, BLOCK *block, ROW *row)
const STRING debug_string() const
C_BLOB_LIST * cblob_list()
void rejection_passes(PAGE_RES *page_res, ETEXT_DESC *monitor, const TBOX *target_word_box, const char *word_config)
void init_to_size(int size, T t)
bool tessedit_minimal_rej_pass1
bool tessedit_display_outwords
bool textord_use_cjk_fp_model
void BestChoiceToCorrectText()
void SwitchAdaptiveClassifier()
TBOX bounding_box() const
WERD * ConstructFromSingleBlob(bool bol, bool eol, C_BLOB *blob)
void ZoomToRectangle(int x1, int y1, int x2, int y2)
C_BLOB_LIST * rej_cblob_list()
bool AdaptableWord(WERD_RES *word)
bool valid_bigram(const WERD_CHOICE &word1, const WERD_CHOICE &word2) const