mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-11-23 18:49:08 +08:00
Use fmtlib for tprintf (unfinished, work in progress)
Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
parent
8d698ed1c9
commit
fef89242a8
@ -1005,10 +1005,10 @@ bool TessBaseAPI::ProcessPagesFileList(FILE *flist, std::string *buf, const char
|
||||
chomp_string(pagename);
|
||||
Pix *pix = pixRead(pagename);
|
||||
if (pix == nullptr) {
|
||||
tprintf("Image file %s cannot be read!\n", pagename);
|
||||
tprintf("Image file {} cannot be read!\n", pagename);
|
||||
return false;
|
||||
}
|
||||
tprintf("Page %u : %s\n", page, pagename);
|
||||
tprintf("Page {} : {}\n", page, pagename);
|
||||
bool r = ProcessPage(pix, page, pagename, retry_config, timeout_millisec, renderer);
|
||||
pixDestroy(&pix);
|
||||
if (!r) {
|
||||
@ -1047,7 +1047,7 @@ bool TessBaseAPI::ProcessPagesMultipageTiff(const l_uint8 *data, size_t size, co
|
||||
}
|
||||
if (offset || page > 0) {
|
||||
// Only print page number for multipage TIFF file.
|
||||
tprintf("Page %d\n", page + 1);
|
||||
tprintf("Page {}\n", page + 1);
|
||||
}
|
||||
auto page_string = std::to_string(page);
|
||||
SetVariable("applybox_page", page_string.c_str());
|
||||
@ -1074,7 +1074,7 @@ bool TessBaseAPI::ProcessPages(const char *filename, const char *retry_config, i
|
||||
#ifndef DISABLED_LEGACY_ENGINE
|
||||
if (result) {
|
||||
if (tesseract_->tessedit_train_from_boxes && !tesseract_->WriteTRFile(output_file_.c_str())) {
|
||||
tprintf("Write of TR file failed: %s\n", output_file_.c_str());
|
||||
tprintf("Write of TR file failed: {}\n", output_file_.c_str());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -1108,7 +1108,7 @@ bool TessBaseAPI::ProcessPagesInternal(const char *filename, const char *retry_c
|
||||
if (stdInput) {
|
||||
#ifdef WIN32
|
||||
if (_setmode(_fileno(stdin), _O_BINARY) == -1)
|
||||
tprintf("ERROR: cin to binary: %s", strerror(errno));
|
||||
tprintf("ERROR: cin to binary: {}", strerror(errno));
|
||||
#endif // WIN32
|
||||
}
|
||||
|
||||
@ -1293,7 +1293,7 @@ bool TessBaseAPI::ProcessPage(Pix *pix, int page_index, const char *filename,
|
||||
// Save current config variables before switching modes.
|
||||
FILE *fp = fopen(kOldVarsFile, "wb");
|
||||
if (fp == nullptr) {
|
||||
tprintf("Error, failed to open file \"%s\"\n", kOldVarsFile);
|
||||
tprintf("Error, failed to open file \"{}\"\n", kOldVarsFile);
|
||||
} else {
|
||||
PrintVariables(fp);
|
||||
fclose(fp);
|
||||
@ -1841,7 +1841,7 @@ bool TessBaseAPI::AdaptToWordStr(PageSegMode mode, const char *wordstr) {
|
||||
SetVariable("classify_enable_learning", "0");
|
||||
const std::unique_ptr<const char[]> text(GetUTF8Text());
|
||||
if (debug) {
|
||||
tprintf("Trying to adapt \"%s\" to \"%s\"\n", text.get(), wordstr);
|
||||
tprintf("Trying to adapt \"{}\" to \"{}\"\n", text.get(), wordstr);
|
||||
}
|
||||
if (text != nullptr) {
|
||||
PAGE_RES_IT it(page_res_);
|
||||
@ -2062,7 +2062,7 @@ bool TessBaseAPI::Threshold(Pix **pix) {
|
||||
if (user_dpi && (user_dpi < kMinCredibleResolution || user_dpi > kMaxCredibleResolution)) {
|
||||
tprintf(
|
||||
"Warning: User defined image dpi is outside of expected range "
|
||||
"(%d - %d)!\n",
|
||||
"({} - {})!\n",
|
||||
kMinCredibleResolution, kMaxCredibleResolution);
|
||||
}
|
||||
// Always use user defined dpi
|
||||
@ -2071,7 +2071,7 @@ bool TessBaseAPI::Threshold(Pix **pix) {
|
||||
} else if (y_res < kMinCredibleResolution || y_res > kMaxCredibleResolution) {
|
||||
if (y_res != 0) {
|
||||
// Show warning only if a resolution was given.
|
||||
tprintf("Warning: Invalid resolution %d dpi. Using %d instead.\n",
|
||||
tprintf("Warning: Invalid resolution {} dpi. Using {} instead.\n",
|
||||
y_res, kMinCredibleResolution);
|
||||
}
|
||||
thresholder_->SetSourceYResolution(kMinCredibleResolution);
|
||||
@ -2116,8 +2116,8 @@ bool TessBaseAPI::Threshold(Pix **pix) {
|
||||
kMinCredibleResolution, kMaxCredibleResolution);
|
||||
if (estimated_res != thresholder_->GetScaledEstimatedResolution()) {
|
||||
tprintf(
|
||||
"Estimated internal resolution %d out of range! "
|
||||
"Corrected to %d.\n",
|
||||
"Estimated internal resolution {} out of range! "
|
||||
"Corrected to {}.\n",
|
||||
thresholder_->GetScaledEstimatedResolution(), estimated_res);
|
||||
}
|
||||
tesseract_->set_source_resolution(estimated_res);
|
||||
|
@ -303,7 +303,7 @@ static void ClipBaseline(int ppi, int x1, int y1, int x2, int y2, int *line_x1,
|
||||
|
||||
static bool CodepointToUtf16be(int code, char utf16[kMaxBytesPerCodepoint]) {
|
||||
if ((code > 0xD7FF && code < 0xE000) || code > 0x10FFFF) {
|
||||
tprintf("Dropping invalid codepoint %d\n", code);
|
||||
tprintf("Dropping invalid codepoint {}\n", code);
|
||||
return false;
|
||||
}
|
||||
if (code < 0x10000) {
|
||||
@ -626,7 +626,7 @@ bool TessPDFRenderer::BeginDocumentHandler() {
|
||||
font = buffer.data();
|
||||
} else {
|
||||
#if !defined(NDEBUG)
|
||||
tprintf("Cannot open file \"%s\"!\nUsing internal glyphless font.\n", stream.str().c_str());
|
||||
tprintf("Cannot open file \"{}\"!\nUsing internal glyphless font.\n", stream.str().c_str());
|
||||
#endif
|
||||
font = pdf_ttf;
|
||||
size = sizeof(pdf_ttf);
|
||||
|
@ -319,7 +319,7 @@ void SIMDDetect::Update() {
|
||||
dotproduct_method = "std::inner_product";
|
||||
} else {
|
||||
// Unsupported value of config variable.
|
||||
tprintf("Warning, ignoring unsupported config variable value: dotproduct=%s\n",
|
||||
tprintf("Warning, ignoring unsupported config variable value: dotproduct={}\n",
|
||||
dotproduct.c_str());
|
||||
tprintf(
|
||||
"Supported values for dotproduct: auto generic native"
|
||||
|
@ -34,7 +34,7 @@ namespace tesseract {
|
||||
bool Tesseract::word_adaptable( // should we adapt?
|
||||
WERD_RES *word, uint16_t mode) {
|
||||
if (tessedit_adaption_debug) {
|
||||
tprintf("Running word_adaptable() for %s rating %.4f certainty %.4f\n",
|
||||
tprintf("Running word_adaptable() for {} rating %.4f certainty %.4f\n",
|
||||
word->best_choice->unichar_string().c_str(), word->best_choice->rating(),
|
||||
word->best_choice->certainty());
|
||||
}
|
||||
@ -112,7 +112,7 @@ bool Tesseract::word_adaptable( // should we adapt?
|
||||
}
|
||||
|
||||
if (tessedit_adaption_debug) {
|
||||
tprintf("returning status %d\n", status);
|
||||
tprintf("returning status {}\n", status);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
@ -310,7 +310,7 @@ static double BoxMissMetric(const TBOX &box1, const TBOX &box2) {
|
||||
bool Tesseract::ResegmentCharBox(PAGE_RES *page_res, const TBOX *prev_box, const TBOX &box,
|
||||
const TBOX *next_box, const char *correct_text) {
|
||||
if (applybox_debug > 1) {
|
||||
tprintf("\nAPPLY_BOX: in ResegmentCharBox() for %s\n", correct_text);
|
||||
tprintf("\nAPPLY_BOX: in ResegmentCharBox() for {}\n", correct_text);
|
||||
}
|
||||
PAGE_RES_IT page_res_it(page_res);
|
||||
WERD_RES *word_res;
|
||||
@ -351,7 +351,7 @@ bool Tesseract::ResegmentCharBox(PAGE_RES *page_res, const TBOX *prev_box, const
|
||||
}
|
||||
if (blob_count > 0) {
|
||||
if (applybox_debug > 1) {
|
||||
tprintf("Index [%d, %d) seem good.\n", i, i + blob_count);
|
||||
tprintf("Index [{}, {}) seem good.\n", i, i + blob_count);
|
||||
}
|
||||
if (!char_box.almost_equal(box, 3) &&
|
||||
((next_box != nullptr && box.x_gap(*next_box) < -3) ||
|
||||
@ -366,7 +366,7 @@ bool Tesseract::ResegmentCharBox(PAGE_RES *page_res, const TBOX *prev_box, const
|
||||
word_res->best_state[i] = blob_count;
|
||||
word_res->correct_text[i] = correct_text;
|
||||
if (applybox_debug > 2) {
|
||||
tprintf("%d Blobs match: blob box:", blob_count);
|
||||
tprintf("{} Blobs match: blob box:", blob_count);
|
||||
word_res->box_word->BlobBox(i).print();
|
||||
tprintf("Matches box:");
|
||||
box.print();
|
||||
@ -386,12 +386,12 @@ bool Tesseract::ResegmentCharBox(PAGE_RES *page_res, const TBOX *prev_box, const
|
||||
if (applybox_debug > 1) {
|
||||
tprintf("Best state = ");
|
||||
for (auto best_state : word_res->best_state) {
|
||||
tprintf("%d ", best_state);
|
||||
tprintf("{} ", best_state);
|
||||
}
|
||||
tprintf("\n");
|
||||
tprintf("Correct text = [[ ");
|
||||
for (auto &it : word_res->correct_text) {
|
||||
tprintf("%s ", it.c_str());
|
||||
tprintf("{} ", it.c_str());
|
||||
}
|
||||
tprintf("]]\n");
|
||||
}
|
||||
@ -414,7 +414,7 @@ bool Tesseract::ResegmentCharBox(PAGE_RES *page_res, const TBOX *prev_box, const
|
||||
bool Tesseract::ResegmentWordBox(BLOCK_LIST *block_list, const TBOX &box, const TBOX *next_box,
|
||||
const char *correct_text) {
|
||||
if (applybox_debug > 1) {
|
||||
tprintf("\nAPPLY_BOX: in ResegmentWordBox() for %s\n", correct_text);
|
||||
tprintf("\nAPPLY_BOX: in ResegmentWordBox() for {}\n", correct_text);
|
||||
}
|
||||
WERD *new_word = nullptr;
|
||||
BLOCK_IT b_it(block_list);
|
||||
@ -503,12 +503,12 @@ void Tesseract::ReSegmentByClassification(PAGE_RES *page_res) {
|
||||
// Convert the correct text to a vector of UNICHAR_ID
|
||||
std::vector<UNICHAR_ID> target_text;
|
||||
if (!ConvertStringToUnichars(word->text(), &target_text)) {
|
||||
tprintf("APPLY_BOX: FAILURE: can't find class_id for '%s'\n", word->text());
|
||||
tprintf("APPLY_BOX: FAILURE: can't find class_id for '{}'\n", word->text());
|
||||
pr_it.DeleteCurrentWord();
|
||||
continue;
|
||||
}
|
||||
if (!FindSegmentation(target_text, word_res)) {
|
||||
tprintf("APPLY_BOX: FAILURE: can't find segmentation for '%s'\n", word->text());
|
||||
tprintf("APPLY_BOX: FAILURE: can't find segmentation for '{}'\n", word->text());
|
||||
pr_it.DeleteCurrentWord();
|
||||
continue;
|
||||
}
|
||||
@ -552,7 +552,7 @@ bool Tesseract::FindSegmentation(const std::vector<UNICHAR_ID> &target_text, WER
|
||||
classify_piece(word_res->seam_array, i, i + j - 1, "Applybox", word_res->chopped_word,
|
||||
word_res->blamer_bundle);
|
||||
if (applybox_debug > 2) {
|
||||
tprintf("%d+%d:", i, j);
|
||||
tprintf("{}+{}:", i, j);
|
||||
print_ratings_list("Segment:", match_result, unicharset);
|
||||
}
|
||||
choices[i].push_back(match_result);
|
||||
@ -662,7 +662,7 @@ void Tesseract::SearchForText(const std::vector<BLOB_CHOICE_LIST *> *choices, in
|
||||
}
|
||||
} else if (choices_pos + length < choices_length && text_index + 1 < target_text.size()) {
|
||||
if (applybox_debug > 3) {
|
||||
tprintf("Match found for %d=%s:%s, at %d+%d, recursing...\n", target_text[text_index],
|
||||
tprintf("Match found for {}={}:{}, at {}+{}, recursing...\n", target_text[text_index],
|
||||
unicharset.id_to_unichar(target_text[text_index]),
|
||||
choice_it.data()->unichar_id() == target_text[text_index] ? "Match" : "Ambig",
|
||||
choices_pos, length);
|
||||
@ -670,7 +670,7 @@ void Tesseract::SearchForText(const std::vector<BLOB_CHOICE_LIST *> *choices, in
|
||||
SearchForText(choices, choices_pos + length, choices_length, target_text, text_index + 1,
|
||||
rating + choice_rating, segmentation, best_rating, best_segmentation);
|
||||
if (applybox_debug > 3) {
|
||||
tprintf("End recursion for %d=%s\n", target_text[text_index],
|
||||
tprintf("End recursion for {}={}\n", target_text[text_index],
|
||||
unicharset.id_to_unichar(target_text[text_index]));
|
||||
}
|
||||
}
|
||||
@ -729,12 +729,12 @@ void Tesseract::TidyUp(PAGE_RES *page_res) {
|
||||
word_res->word->set_flag(W_EOL, pr_it.next_row() != pr_it.row());
|
||||
}
|
||||
if (applybox_debug > 0) {
|
||||
tprintf(" Found %d good blobs.\n", ok_blob_count);
|
||||
tprintf(" Found {} good blobs.\n", ok_blob_count);
|
||||
if (bad_blob_count > 0) {
|
||||
tprintf(" Leaving %d unlabelled blobs in %d words.\n", bad_blob_count, ok_word_count);
|
||||
tprintf(" Leaving {} unlabelled blobs in {} words.\n", bad_blob_count, ok_word_count);
|
||||
}
|
||||
if (unlabelled_words > 0) {
|
||||
tprintf(" %d remaining unlabelled words deleted.\n", unlabelled_words);
|
||||
tprintf(" {} remaining unlabelled words deleted.\n", unlabelled_words);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -742,7 +742,7 @@ void Tesseract::TidyUp(PAGE_RES *page_res) {
|
||||
/** Logs a bad box by line in the box file and box coords.*/
|
||||
void Tesseract::ReportFailedBox(int boxfile_lineno, TBOX box, const char *box_ch,
|
||||
const char *err_msg) {
|
||||
tprintf("APPLY_BOXES: boxfile line %d/%s ((%d,%d),(%d,%d)): %s\n", boxfile_lineno + 1, box_ch,
|
||||
tprintf("APPLY_BOXES: boxfile line {}/{} (({},{}),({},{})): {}\n", boxfile_lineno + 1, box_ch,
|
||||
box.left(), box.bottom(), box.right(), box.top(), err_msg);
|
||||
}
|
||||
|
||||
@ -755,7 +755,7 @@ void Tesseract::ApplyBoxTraining(const std::string &fontname, PAGE_RES *page_res
|
||||
LearnWord(fontname.c_str(), word_res);
|
||||
++word_count;
|
||||
}
|
||||
tprintf("Generated training data for %d words\n", word_count);
|
||||
tprintf("Generated training data for {} words\n", word_count);
|
||||
}
|
||||
|
||||
#endif // ndef DISABLED_LEGACY_ENGINE
|
||||
|
@ -91,8 +91,8 @@ bool Tesseract::recog_interactive(PAGE_RES_IT *pr_it) {
|
||||
WERD_RES *word_res = pr_it->word();
|
||||
word_char_quality(word_res, &char_qual, &good_char_qual);
|
||||
tprintf(
|
||||
"\n%d chars; word_blob_quality: %d; outline_errs: %d; "
|
||||
"char_quality: %d; good_char_quality: %d\n",
|
||||
"\n{} chars; word_blob_quality: {}; outline_errs: {}; "
|
||||
"char_quality: {}; good_char_quality: {}\n",
|
||||
word_res->reject_map.length(), word_blob_quality(word_res), word_outline_errs(word_res),
|
||||
char_qual, good_char_qual);
|
||||
}
|
||||
@ -123,7 +123,7 @@ bool Tesseract::ProcessTargetWord(const TBOX &word_box, const TBOX &target_word_
|
||||
backup_config_file_ = kBackUpConfigFile;
|
||||
FILE *config_fp = fopen(backup_config_file_, "wb");
|
||||
if (config_fp == nullptr) {
|
||||
tprintf("Error, failed to open file \"%s\"\n", backup_config_file_);
|
||||
tprintf("Error, failed to open file \"{}\"\n", backup_config_file_);
|
||||
} else {
|
||||
ParamUtils::PrintParams(config_fp, params());
|
||||
fclose(config_fp);
|
||||
@ -252,8 +252,8 @@ bool Tesseract::RecogAllWordsPassN(int pass_n, ETEXT_DESC *monitor, PAGE_RES_IT
|
||||
|
||||
classify_word_and_language(pass_n, pr_it, word);
|
||||
if (tessedit_dump_choices || debug_noise_removal) {
|
||||
tprintf("Pass%d: %s [%s]\n", pass_n, word->word->best_choice->unichar_string().c_str(),
|
||||
word->word->best_choice->debug_string().c_str());
|
||||
tprintf("Pass{}: {} [{}]\n", pass_n, word->word->best_choice->unichar_string(),
|
||||
word->word->best_choice->debug_string());
|
||||
}
|
||||
pr_it->forward();
|
||||
if (make_next_word_fuzzy && pr_it->word() != nullptr) {
|
||||
@ -497,13 +497,13 @@ void Tesseract::bigram_correction_pass(PAGE_RES *page_res) {
|
||||
|
||||
if (w->tesseract->getDict().valid_bigram(prev_best, this_best)) {
|
||||
if (tessedit_bigram_debug) {
|
||||
tprintf("Top choice \"%s %s\" verified by bigram model.\n", orig_w1_str.c_str(),
|
||||
orig_w2_str.c_str());
|
||||
tprintf("Top choice \"{} {}\" verified by bigram model.\n", orig_w1_str,
|
||||
orig_w2_str);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (tessedit_bigram_debug > 2) {
|
||||
tprintf("Examining alt choices for \"%s %s\".\n", orig_w1_str.c_str(), orig_w2_str.c_str());
|
||||
tprintf("Examining alt choices for \"{} {}\".\n", orig_w1_str, orig_w2_str);
|
||||
}
|
||||
if (tessedit_bigram_debug > 1) {
|
||||
if (!w_prev->best_choices.singleton()) {
|
||||
@ -549,9 +549,9 @@ void Tesseract::bigram_correction_pass(PAGE_RES *page_res) {
|
||||
EqualIgnoringCaseAndTerminalPunct(*w->best_choice, *overrides_word2[best_idx])) {
|
||||
if (tessedit_bigram_debug > 1) {
|
||||
tprintf(
|
||||
"Top choice \"%s %s\" verified (sans case) by bigram "
|
||||
"Top choice \"{} {}\" verified (sans case) by bigram "
|
||||
"model.\n",
|
||||
orig_w1_str.c_str(), orig_w2_str.c_str());
|
||||
orig_w1_str, orig_w2_str);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@ -588,9 +588,9 @@ void Tesseract::bigram_correction_pass(PAGE_RES *page_res) {
|
||||
choices_description += " compatible bigrams.";
|
||||
}
|
||||
}
|
||||
tprintf("Replaced \"%s %s\" with \"%s %s\" with bigram model. %s\n", orig_w1_str.c_str(),
|
||||
orig_w2_str.c_str(), new_w1_str.c_str(), new_w2_str.c_str(),
|
||||
choices_description.c_str());
|
||||
tprintf("Replaced \"{} {}\" with \"{} {}\" with bigram model. %s\n", orig_w1_str,
|
||||
orig_w2_str, new_w1_str, new_w2_str,
|
||||
choices_description);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -652,8 +652,7 @@ void Tesseract::rejection_passes(PAGE_RES *page_res, ETEXT_DESC *monitor,
|
||||
}
|
||||
|
||||
if (tessedit_debug_quality_metrics) {
|
||||
tprintf(
|
||||
"QUALITY: num_chs= %d num_rejs= %d %5.3f blob_qual= %d %5.3f"
|
||||
tprintf("QUALITY: num_chs= %d num_rejs= %d %5.3f blob_qual= %d %5.3f"
|
||||
" outline_errs= %d %5.3f char_qual= %d %5.3f good_ch_qual= %d %5.3f\n",
|
||||
page_res->char_count, page_res->rej_count,
|
||||
page_res->rej_count / static_cast<float>(page_res->char_count), stats_.doc_blob_quality,
|
||||
@ -692,13 +691,13 @@ void Tesseract::blamer_pass(PAGE_RES *page_res) {
|
||||
}
|
||||
tprintf("Blame reasons:\n");
|
||||
for (int bl = 0; bl < IRR_NUM_REASONS; ++bl) {
|
||||
tprintf("%s %d\n", BlamerBundle::IncorrectReasonName(static_cast<IncorrectResultReason>(bl)),
|
||||
tprintf("{} {}\n", BlamerBundle::IncorrectReasonName(static_cast<IncorrectResultReason>(bl)),
|
||||
page_res->blame_reasons[bl]);
|
||||
}
|
||||
if (page_res->misadaption_log.size() > 0) {
|
||||
tprintf("Misadaption log:\n");
|
||||
for (auto &log : page_res->misadaption_log) {
|
||||
tprintf("%s\n", log.c_str());
|
||||
tprintf("{}\n", log);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -223,12 +223,12 @@ void Tesseract::doc_and_block_rejection( // reject big chunks
|
||||
tessedit_reject_doc_percent) {
|
||||
reject_whole_page(page_res_it);
|
||||
if (tessedit_debug_doc_rejection) {
|
||||
tprintf("REJECT ALL #chars: %d #Rejects: %d; \n", page_res_it.page_res->char_count,
|
||||
tprintf("REJECT ALL #chars: {} #Rejects: {}; \n", page_res_it.page_res->char_count,
|
||||
page_res_it.page_res->rej_count);
|
||||
}
|
||||
} else {
|
||||
if (tessedit_debug_doc_rejection) {
|
||||
tprintf("NO PAGE REJECTION #chars: %d # Rejects: %d; \n", page_res_it.page_res->char_count,
|
||||
tprintf("NO PAGE REJECTION #chars: {} # Rejects: {}; \n", page_res_it.page_res->char_count,
|
||||
page_res_it.page_res->rej_count);
|
||||
}
|
||||
|
||||
@ -243,7 +243,7 @@ void Tesseract::doc_and_block_rejection( // reject big chunks
|
||||
(current_block->rej_count * 100.0 / current_block->char_count) >
|
||||
tessedit_reject_block_percent) {
|
||||
if (tessedit_debug_block_rejection) {
|
||||
tprintf("REJECTING BLOCK %d #chars: %d; #Rejects: %d\n", block_no,
|
||||
tprintf("REJECTING BLOCK {} #chars: {}; #Rejects: {}\n", block_no,
|
||||
current_block->char_count, current_block->rej_count);
|
||||
}
|
||||
prev_word_rejected = false;
|
||||
@ -279,7 +279,7 @@ void Tesseract::doc_and_block_rejection( // reject big chunks
|
||||
}
|
||||
} else {
|
||||
if (tessedit_debug_block_rejection) {
|
||||
tprintf("NOT REJECTING BLOCK %d #chars: %d # Rejects: %d; \n", block_no,
|
||||
tprintf("NOT REJECTING BLOCK {} #chars: {} # Rejects: {}; \n", block_no,
|
||||
page_res_it.block()->char_count, page_res_it.block()->rej_count);
|
||||
}
|
||||
|
||||
@ -299,7 +299,7 @@ void Tesseract::doc_and_block_rejection( // reject big chunks
|
||||
(current_row->whole_word_rej_count * 100.0 / current_row->rej_count) <
|
||||
tessedit_whole_wd_rej_row_percent) {
|
||||
if (tessedit_debug_block_rejection) {
|
||||
tprintf("REJECTING ROW %d #chars: %d; #Rejects: %d\n", row_no,
|
||||
tprintf("REJECTING ROW {} #chars: {}; #Rejects: {}\n", row_no,
|
||||
current_row->char_count, current_row->rej_count);
|
||||
}
|
||||
prev_word_rejected = false;
|
||||
@ -341,7 +341,7 @@ void Tesseract::doc_and_block_rejection( // reject big chunks
|
||||
}
|
||||
} else {
|
||||
if (tessedit_debug_block_rejection) {
|
||||
tprintf("NOT REJECTING ROW %d #chars: %d # Rejects: %d; \n", row_no,
|
||||
tprintf("NOT REJECTING ROW {} #chars: {} # Rejects: {}; \n", row_no,
|
||||
current_row->char_count, current_row->rej_count);
|
||||
}
|
||||
while (page_res_it.word() != nullptr && page_res_it.row() == current_row) {
|
||||
@ -405,13 +405,13 @@ void Tesseract::tilde_crunch(PAGE_RES_IT &page_res_it) {
|
||||
|
||||
if ((garbage_level != G_NEVER_CRUNCH) && (terrible_word_crunch(word, garbage_level))) {
|
||||
if (crunch_debug > 0) {
|
||||
tprintf("T CRUNCHING: \"%s\"\n", word->best_choice->unichar_string().c_str());
|
||||
tprintf("T CRUNCHING: \"{}\"\n", word->best_choice->unichar_string().c_str());
|
||||
}
|
||||
word->unlv_crunch_mode = CR_KEEP_SPACE;
|
||||
if (prev_potential_marked) {
|
||||
while (copy_it.word() != word) {
|
||||
if (crunch_debug > 0) {
|
||||
tprintf("P1 CRUNCHING: \"%s\"\n",
|
||||
tprintf("P1 CRUNCHING: \"{}\"\n",
|
||||
copy_it.word()->best_choice->unichar_string().c_str());
|
||||
}
|
||||
copy_it.word()->unlv_crunch_mode = CR_KEEP_SPACE;
|
||||
@ -424,14 +424,14 @@ void Tesseract::tilde_crunch(PAGE_RES_IT &page_res_it) {
|
||||
(potential_word_crunch(word, garbage_level, ok_dict_word))) {
|
||||
if (found_terrible_word) {
|
||||
if (crunch_debug > 0) {
|
||||
tprintf("P2 CRUNCHING: \"%s\"\n", word->best_choice->unichar_string().c_str());
|
||||
tprintf("P2 CRUNCHING: \"{}\"\n", word->best_choice->unichar_string().c_str());
|
||||
}
|
||||
word->unlv_crunch_mode = CR_KEEP_SPACE;
|
||||
} else if (!prev_potential_marked) {
|
||||
copy_it = page_res_it;
|
||||
prev_potential_marked = true;
|
||||
if (crunch_debug > 1) {
|
||||
tprintf("P3 CRUNCHING: \"%s\"\n", word->best_choice->unichar_string().c_str());
|
||||
tprintf("P3 CRUNCHING: \"{}\"\n", word->best_choice->unichar_string().c_str());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -439,7 +439,7 @@ void Tesseract::tilde_crunch(PAGE_RES_IT &page_res_it) {
|
||||
// Forget earlier potential crunches
|
||||
prev_potential_marked = false;
|
||||
if (crunch_debug > 2) {
|
||||
tprintf("NO CRUNCH: \"%s\"\n", word->best_choice->unichar_string().c_str());
|
||||
tprintf("NO CRUNCH: \"{}\"\n", word->best_choice->unichar_string().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -476,8 +476,8 @@ bool Tesseract::terrible_word_crunch(WERD_RES *word, GARBAGE_LEVEL garbage_level
|
||||
}
|
||||
if (crunch_mode > 0) {
|
||||
if (crunch_debug > 2) {
|
||||
tprintf("Terrible_word_crunch (%d) on \"%s\"\n", crunch_mode,
|
||||
word->best_choice->unichar_string().c_str());
|
||||
tprintf("Terrible_word_crunch ({}) on \"{}\"\n", crunch_mode,
|
||||
word->best_choice->unichar_string());
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
@ -506,21 +506,21 @@ bool Tesseract::potential_word_crunch(WERD_RES *word, GARBAGE_LEVEL garbage_leve
|
||||
|
||||
if (rating_per_ch > crunch_pot_poor_rate) {
|
||||
if (crunch_debug > 2) {
|
||||
tprintf("Potential poor rating on \"%s\"\n", word->best_choice->unichar_string().c_str());
|
||||
tprintf("Potential poor rating on \"{}\"\n", word->best_choice->unichar_string());
|
||||
}
|
||||
poor_indicator_count++;
|
||||
}
|
||||
|
||||
if (word_crunchable && word->best_choice->certainty() < crunch_pot_poor_cert) {
|
||||
if (crunch_debug > 2) {
|
||||
tprintf("Potential poor cert on \"%s\"\n", word->best_choice->unichar_string().c_str());
|
||||
tprintf("Potential poor cert on \"{}\"\n", word->best_choice->unichar_string());
|
||||
}
|
||||
poor_indicator_count++;
|
||||
}
|
||||
|
||||
if (garbage_level != G_OK) {
|
||||
if (crunch_debug > 2) {
|
||||
tprintf("Potential garbage on \"%s\"\n", word->best_choice->unichar_string().c_str());
|
||||
tprintf("Potential garbage on \"{}\"\n", word->best_choice->unichar_string());
|
||||
}
|
||||
poor_indicator_count++;
|
||||
}
|
||||
@ -545,8 +545,8 @@ void Tesseract::tilde_delete(PAGE_RES_IT &page_res_it) {
|
||||
if (delete_mode != CR_NONE) {
|
||||
if (word->word->flag(W_BOL) || deleting_from_bol) {
|
||||
if (crunch_debug > 0) {
|
||||
tprintf("BOL CRUNCH DELETING(%d): \"%s\"\n", debug_delete_mode,
|
||||
word->best_choice->unichar_string().c_str());
|
||||
tprintf("BOL CRUNCH DELETING({}): \"{}\"\n", debug_delete_mode,
|
||||
word->best_choice->unichar_string());
|
||||
}
|
||||
word->unlv_crunch_mode = delete_mode;
|
||||
deleting_from_bol = true;
|
||||
@ -555,16 +555,16 @@ void Tesseract::tilde_delete(PAGE_RES_IT &page_res_it) {
|
||||
while (copy_it.word() != word) {
|
||||
x_delete_mode = word_deletable(copy_it.word(), x_debug_delete_mode);
|
||||
if (crunch_debug > 0) {
|
||||
tprintf("EOL CRUNCH DELETING(%d): \"%s\"\n", x_debug_delete_mode,
|
||||
copy_it.word()->best_choice->unichar_string().c_str());
|
||||
tprintf("EOL CRUNCH DELETING({}): \"{}\"\n", x_debug_delete_mode,
|
||||
copy_it.word()->best_choice->unichar_string());
|
||||
}
|
||||
copy_it.word()->unlv_crunch_mode = x_delete_mode;
|
||||
copy_it.forward();
|
||||
}
|
||||
}
|
||||
if (crunch_debug > 0) {
|
||||
tprintf("EOL CRUNCH DELETING(%d): \"%s\"\n", debug_delete_mode,
|
||||
word->best_choice->unichar_string().c_str());
|
||||
tprintf("EOL CRUNCH DELETING({}): \"{}\"\n", debug_delete_mode,
|
||||
word->best_choice->unichar_string());
|
||||
}
|
||||
word->unlv_crunch_mode = delete_mode;
|
||||
deleting_from_bol = false;
|
||||
@ -776,8 +776,8 @@ GARBAGE_LEVEL Tesseract::garbage_word(WERD_RES *word, bool ok_dict_word) {
|
||||
ok_chars = len - bad_char_count - isolated_digits - isolated_alphas - tess_rejs;
|
||||
|
||||
if (crunch_debug > 3) {
|
||||
tprintf("garbage_word: \"%s\"\n", word->best_choice->unichar_string().c_str());
|
||||
tprintf("LEN: %d bad: %d iso_N: %d iso_A: %d rej: %d\n", len, bad_char_count,
|
||||
tprintf("garbage_word: \"{}\"\n", word->best_choice->unichar_string());
|
||||
tprintf("LEN: {} bad: {} iso_N: {} iso_A: {} rej: {}\n", len, bad_char_count,
|
||||
isolated_digits, isolated_alphas, tess_rejs);
|
||||
}
|
||||
if (bad_char_count == 0 && tess_rejs == 0 &&
|
||||
|
@ -481,28 +481,28 @@ void Tesseract::dump_words(WERD_RES_LIST &perm, int16_t score, int16_t mode, boo
|
||||
if (debug_fix_space_level > 1) {
|
||||
switch (mode) {
|
||||
case 1:
|
||||
tprintf("EXTRACTED (%d): \"", score);
|
||||
tprintf("EXTRACTED ({}): \"", score);
|
||||
break;
|
||||
case 2:
|
||||
tprintf("TESTED (%d): \"", score);
|
||||
tprintf("TESTED ({}): \"", score);
|
||||
break;
|
||||
case 3:
|
||||
tprintf("RETURNED (%d): \"", score);
|
||||
tprintf("RETURNED ({}): \"", score);
|
||||
break;
|
||||
}
|
||||
|
||||
for (word_res_it.mark_cycle_pt(); !word_res_it.cycled_list(); word_res_it.forward()) {
|
||||
if (!word_res_it.data()->part_of_combo) {
|
||||
tprintf("%s/%1d ", word_res_it.data()->best_choice->unichar_string().c_str(),
|
||||
tprintf("{}/%1d ", word_res_it.data()->best_choice->unichar_string(),
|
||||
static_cast<int>(word_res_it.data()->best_choice->permuter()));
|
||||
}
|
||||
}
|
||||
tprintf("\"\n");
|
||||
} else if (improved) {
|
||||
tprintf("FIX SPACING \"%s\" => \"", stats_.dump_words_str.c_str());
|
||||
tprintf("FIX SPACING \"{}\" => \"", stats_.dump_words_str);
|
||||
for (word_res_it.mark_cycle_pt(); !word_res_it.cycled_list(); word_res_it.forward()) {
|
||||
if (!word_res_it.data()->part_of_combo) {
|
||||
tprintf("%s/%1d ", word_res_it.data()->best_choice->unichar_string().c_str(),
|
||||
tprintf("{}/%1d ", word_res_it.data()->best_choice->unichar_string(),
|
||||
static_cast<int>(word_res_it.data()->best_choice->permuter()));
|
||||
}
|
||||
}
|
||||
@ -562,7 +562,7 @@ void Tesseract::fix_sp_fp_word(WERD_RES_IT &word_res_it, ROW *row, BLOCK *block)
|
||||
}
|
||||
|
||||
if (debug_fix_space_level > 1) {
|
||||
tprintf("FP fixspace working on \"%s\"\n", word_res->best_choice->unichar_string().c_str());
|
||||
tprintf("FP fixspace working on \"{}\"\n", word_res->best_choice->unichar_string());
|
||||
}
|
||||
word_res->word->rej_cblob_list()->sort(c_blob_comparator);
|
||||
sub_word_list_it.add_after_stay_put(word_res_it.extract());
|
||||
@ -706,8 +706,8 @@ int16_t Tesseract::worst_noise_blob(WERD_RES *word_res, float *worst_noise_score
|
||||
|
||||
#ifndef SECURE_NAMES
|
||||
if (debug_fix_space_level > 5) {
|
||||
tprintf("FP fixspace Noise metrics for \"%s\": ",
|
||||
word_res->best_choice->unichar_string().c_str());
|
||||
tprintf("FP fixspace Noise metrics for \"{}\": ",
|
||||
word_res->best_choice->unichar_string());
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -809,21 +809,21 @@ void fixspace_dbg(WERD_RES *word) {
|
||||
int16_t i;
|
||||
|
||||
box.print();
|
||||
tprintf(" \"%s\" ", word->best_choice->unichar_string().c_str());
|
||||
tprintf("Blob count: %d (word); %d/%d (rebuild word)\n", word->word->cblob_list()->length(),
|
||||
tprintf(" \"{}\" ", word->best_choice->unichar_string());
|
||||
tprintf("Blob count: {} (word); {}/{} (rebuild word)\n", word->word->cblob_list()->length(),
|
||||
word->rebuild_word->NumBlobs(), word->box_word->length());
|
||||
word->reject_map.print(debug_fp);
|
||||
tprintf("\n");
|
||||
if (show_map_detail) {
|
||||
tprintf("\"%s\"\n", word->best_choice->unichar_string().c_str());
|
||||
tprintf("\"{}\"\n", word->best_choice->unichar_string());
|
||||
for (i = 0; word->best_choice->unichar_string()[i] != '\0'; i++) {
|
||||
tprintf("**** \"%c\" ****\n", word->best_choice->unichar_string()[i]);
|
||||
word->reject_map[i].full_print(debug_fp);
|
||||
}
|
||||
}
|
||||
|
||||
tprintf("Tess Accepted: %s\n", word->tess_accepted ? "TRUE" : "FALSE");
|
||||
tprintf("Done flag: %s\n\n", word->done ? "TRUE" : "FALSE");
|
||||
tprintf("Tess Accepted: {}\n", word->tess_accepted ? "TRUE" : "FALSE");
|
||||
tprintf("Done flag: {}\n\n", word->done ? "TRUE" : "FALSE");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2,7 +2,6 @@
|
||||
* File: fixxht.cpp (Formerly fixxht.c)
|
||||
* Description: Improve x_ht and look out for case inconsistencies
|
||||
* Author: Phil Cheatle
|
||||
* Created: Thu Aug 5 14:11:08 BST 1993
|
||||
*
|
||||
* (C) Copyright 1992, Hewlett-Packard Ltd.
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -91,7 +90,7 @@ int Tesseract::CountMisfitTops(WERD_RES *word_res) {
|
||||
++bad_blobs;
|
||||
}
|
||||
if (debug_x_ht_level >= 1) {
|
||||
tprintf("Class %s is %s with top %d vs limits of %d->%d, +/-%d\n",
|
||||
tprintf("Class {} is {} with top {} vs limits of {}->{}, +/-{}\n",
|
||||
unicharset.id_to_unichar(class_id), bad ? "Misfit" : "OK", top, min_top, max_top,
|
||||
static_cast<int>(x_ht_acceptance_tolerance));
|
||||
}
|
||||
@ -130,7 +129,7 @@ float Tesseract::ComputeCompatibleXheight(WERD_RES *word_res, float *baseline_sh
|
||||
top - (max_top + x_ht_acceptance_tolerance));
|
||||
int height = top - kBlnBaselineOffset;
|
||||
if (debug_x_ht_level >= 2) {
|
||||
tprintf("Class %s: height=%d, bottom=%d,%d top=%d,%d, actual=%d,%d: ",
|
||||
tprintf("Class {}: height={}, bottom={},{} top={},{}, actual={},{}: ",
|
||||
unicharset.id_to_unichar(class_id), height, min_bottom, max_bottom, min_top,
|
||||
max_top, bottom, top);
|
||||
}
|
||||
@ -144,7 +143,7 @@ float Tesseract::ComputeCompatibleXheight(WERD_RES *word_res, float *baseline_sh
|
||||
int min_xht = DivRounded(height * kBlnXHeight, max_top - kBlnBaselineOffset);
|
||||
int max_xht = DivRounded(height * kBlnXHeight, min_top - kBlnBaselineOffset);
|
||||
if (debug_x_ht_level >= 2) {
|
||||
tprintf(" xht range min=%d, max=%d\n", min_xht, max_xht);
|
||||
tprintf(" xht range min={}, max={}\n", min_xht, max_xht);
|
||||
}
|
||||
// The range of expected heights gets a vote equal to the distance
|
||||
// of the actual top from the expected top.
|
||||
@ -158,7 +157,7 @@ float Tesseract::ComputeCompatibleXheight(WERD_RES *word_res, float *baseline_sh
|
||||
int min_shift = min_bottom - bottom;
|
||||
int max_shift = max_bottom - bottom;
|
||||
if (debug_x_ht_level >= 2) {
|
||||
tprintf(" bottom shift min=%d, max=%d\n", min_shift, max_shift);
|
||||
tprintf(" bottom shift min={}, max={}\n", min_shift, max_shift);
|
||||
}
|
||||
// The range of expected shifts gets a vote equal to the min distance
|
||||
// of the actual bottom from the expected bottom, spread over the
|
||||
@ -185,7 +184,7 @@ float Tesseract::ComputeCompatibleXheight(WERD_RES *word_res, float *baseline_sh
|
||||
if (shift_stats.get_total() > top_stats.get_total()) {
|
||||
bottom_shift = IntCastRounded(shift_stats.median());
|
||||
if (debug_x_ht_level >= 2) {
|
||||
tprintf("Applying bottom shift=%d\n", bottom_shift);
|
||||
tprintf("Applying bottom shift={}\n", bottom_shift);
|
||||
}
|
||||
}
|
||||
} while (bottom_shift != 0 && top_stats.get_total() < shift_stats.get_total());
|
||||
|
@ -45,7 +45,7 @@ bool Tesseract::TrainLineRecognizer(const char *input_imagename, const std::stri
|
||||
if (applybox_page > 0) {
|
||||
// Load existing document for the previous pages.
|
||||
if (!images.LoadDocument(lstmf_name.c_str(), 0, 0, nullptr)) {
|
||||
tprintf("Failed to read training data from %s!\n", lstmf_name.c_str());
|
||||
tprintf("Failed to read training data from {}!\n", lstmf_name);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -54,17 +54,17 @@ bool Tesseract::TrainLineRecognizer(const char *input_imagename, const std::stri
|
||||
// Get the boxes for this page, if there are any.
|
||||
if (!ReadAllBoxes(applybox_page, false, input_imagename, &boxes, &texts, nullptr, nullptr) ||
|
||||
boxes.empty()) {
|
||||
tprintf("Failed to read boxes from %s\n", input_imagename);
|
||||
tprintf("Failed to read boxes from {}\n", input_imagename);
|
||||
return false;
|
||||
}
|
||||
TrainFromBoxes(boxes, texts, block_list, &images);
|
||||
if (images.PagesSize() == 0) {
|
||||
tprintf("Failed to read pages from %s\n", input_imagename);
|
||||
tprintf("Failed to read pages from {}\n", input_imagename);
|
||||
return false;
|
||||
}
|
||||
images.Shuffle();
|
||||
if (!images.SaveDocument(lstmf_name.c_str(), nullptr)) {
|
||||
tprintf("Failed to write training data to %s!\n", lstmf_name.c_str());
|
||||
tprintf("Failed to write training data to {}!\n", lstmf_name);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -112,7 +112,7 @@ void Tesseract::TrainFromBoxes(const std::vector<TBOX> &boxes, const std::vector
|
||||
}
|
||||
ImageData *imagedata = nullptr;
|
||||
if (best_block == nullptr) {
|
||||
tprintf("No block overlapping textline: %s\n", line_str.c_str());
|
||||
tprintf("No block overlapping textline: {}\n", line_str);
|
||||
} else {
|
||||
imagedata = GetLineData(line_box, boxes, texts, start_box, end_box, *best_block);
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ void Tesseract::write_results(PAGE_RES_IT &page_res_it,
|
||||
set_unlv_suspects(word);
|
||||
check_debug_pt(word, 120);
|
||||
if (tessedit_rejection_debug) {
|
||||
tprintf("Dict word: \"%s\": %d\n", word->best_choice->debug_string().c_str(),
|
||||
tprintf("Dict word: \"{}\": {}\n", word->best_choice->debug_string(),
|
||||
dict_word(*(word->best_choice)));
|
||||
}
|
||||
if (!word->word->flag(W_REP_CHAR) || !tessedit_write_rep_codes) {
|
||||
@ -232,7 +232,7 @@ char determine_newline_type( // test line ends
|
||||
end_gap = block_box.right() - word_box.right();
|
||||
end_gap -= static_cast<int32_t>(block->space());
|
||||
width = next_box.right() - next_box.left();
|
||||
// tprintf("end_gap=%d-%d=%d, width=%d-%d=%d, nl=%d\n",
|
||||
// tprintf("end_gap={}-{}={}, width={}-{}={}, nl={}\n",
|
||||
// block_box.right(),word_box.right(),end_gap,
|
||||
// next_box.right(),next_box.left(),width,
|
||||
// end_gap>width ? CTRL_HARDLINE : CTRL_NEWLINE);
|
||||
|
@ -648,8 +648,8 @@ void PageIterator::BeginWord(int offset) {
|
||||
word_length_ = word_res->best_choice->length();
|
||||
if (word_res->box_word != nullptr) {
|
||||
if (word_res->box_word->length() != static_cast<unsigned>(word_length_)) {
|
||||
tprintf("Corrupted word! best_choice[len=%d] = %s, box_word[len=%d]: ",
|
||||
word_length_, word_res->best_choice->unichar_string().c_str(),
|
||||
tprintf("Corrupted word! best_choice[len={}] = {}, box_word[len={}]: ",
|
||||
word_length_, word_res->best_choice->unichar_string(),
|
||||
word_res->box_word->length());
|
||||
word_res->box_word->bounding_box().print();
|
||||
}
|
||||
|
@ -74,13 +74,13 @@ static bool AcceptableRowArgs(int debug_level, int min_num_rows, const char *fun
|
||||
const std::vector<RowScratchRegisters> *rows, int row_start,
|
||||
int row_end) {
|
||||
if (row_start < 0 || static_cast<size_t>(row_end) > rows->size() || row_start > row_end) {
|
||||
tprintf("Invalid arguments rows[%d, %d) while rows is of size %zu.\n", row_start, row_end,
|
||||
tprintf("Invalid arguments rows[{}, {}) while rows is of size {}.\n", row_start, row_end,
|
||||
rows->size());
|
||||
return false;
|
||||
}
|
||||
if (row_end - row_start < min_num_rows) {
|
||||
if (debug_level > 1) {
|
||||
tprintf("# Too few rows[%d, %d) for %s.\n", row_start, row_end, function_name);
|
||||
tprintf("# Too few rows[{}, {}) for {}.\n", row_start, row_end, function_name);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -121,7 +121,7 @@ static void PrintTable(const std::vector<std::vector<std::string>> &rows, const
|
||||
for (const auto &row : rows) {
|
||||
for (unsigned c = 0; c < row.size(); c++) {
|
||||
if (c > 0) {
|
||||
tprintf("%s", colsep);
|
||||
tprintf("{}", colsep);
|
||||
}
|
||||
tprintf(col_width_patterns[c].c_str(), row[c].c_str());
|
||||
}
|
||||
@ -172,7 +172,7 @@ static void PrintDetectorState(const ParagraphTheory &theory,
|
||||
tprintf("Active Paragraph Models:\n");
|
||||
unsigned m = 0;
|
||||
for (const auto &model : theory.models()) {
|
||||
tprintf(" %d: %s\n", ++m, model->ToString().c_str());
|
||||
tprintf(" {}: {}\n", ++m, model->ToString());
|
||||
}
|
||||
}
|
||||
|
||||
@ -181,7 +181,7 @@ static void DebugDump(bool should_print, const char *phase, const ParagraphTheor
|
||||
if (!should_print) {
|
||||
return;
|
||||
}
|
||||
tprintf("# %s\n", phase);
|
||||
tprintf("# {}\n", phase);
|
||||
PrintDetectorState(theory, rows);
|
||||
}
|
||||
|
||||
@ -190,7 +190,7 @@ static void PrintRowRange(const std::vector<RowScratchRegisters> &rows, int row_
|
||||
int row_end) {
|
||||
tprintf("======================================\n");
|
||||
for (int row = row_start; row < row_end; row++) {
|
||||
tprintf("%s\n", rows[row].ri_->text.c_str());
|
||||
tprintf("{}\n", rows[row].ri_->text.c_str());
|
||||
}
|
||||
tprintf("======================================\n");
|
||||
}
|
||||
@ -912,8 +912,8 @@ struct GeometricClassifierState {
|
||||
CalculateTabStops(r, r_start, r_end, tolerance, &left_tabs, &right_tabs);
|
||||
if (debug_level >= 3) {
|
||||
tprintf(
|
||||
"Geometry: TabStop cluster tolerance = %d; "
|
||||
"%zu left tabs; %zu right tabs\n",
|
||||
"Geometry: TabStop cluster tolerance = {}; "
|
||||
"{} left tabs; {} right tabs\n",
|
||||
tolerance, left_tabs.size(), right_tabs.size());
|
||||
}
|
||||
ltr = (*r)[r_start].ri_->ltr;
|
||||
@ -974,7 +974,7 @@ struct GeometricClassifierState {
|
||||
if (debug_level < min_debug_level) {
|
||||
return;
|
||||
}
|
||||
tprintf("# %s\n", why);
|
||||
tprintf("# {}\n", why);
|
||||
PrintRows();
|
||||
}
|
||||
|
||||
@ -1071,7 +1071,7 @@ static void GeometricClassifyThreeTabStopTextBlock(int debug_level, GeometricCla
|
||||
if (debug_level > 0) {
|
||||
tprintf(
|
||||
"# Not enough variety for clear outline classification. "
|
||||
"Guessing these are %s aligned based on script.\n",
|
||||
"Guessing these are {} aligned based on script.\n",
|
||||
s.ltr ? "left" : "right");
|
||||
s.PrintRows();
|
||||
}
|
||||
@ -1138,7 +1138,7 @@ static void GeometricClassify(int debug_level, std::vector<RowScratchRegisters>
|
||||
}
|
||||
if (debug_level > 1) {
|
||||
tprintf("###############################################\n");
|
||||
tprintf("##### GeometricClassify( rows[%d:%d) ) ####\n", row_start, row_end);
|
||||
tprintf("##### GeometricClassify( rows[{}:{}) ) ####\n", row_start, row_end);
|
||||
tprintf("###############################################\n");
|
||||
}
|
||||
RecomputeMarginsAndClearHypotheses(rows, row_start, row_end, 10);
|
||||
@ -1213,11 +1213,11 @@ static void GeometricClassify(int debug_level, std::vector<RowScratchRegisters>
|
||||
} else {
|
||||
// Ambiguous! Probably lineated (poetry)
|
||||
if (debug_level > 1) {
|
||||
tprintf("# Cannot determine %s indent likely to start paragraphs.\n",
|
||||
tprintf("# Cannot determine {} indent likely to start paragraphs.\n",
|
||||
s.just == tesseract::JUSTIFICATION_LEFT ? "left" : "right");
|
||||
tprintf("# Indent of %d looks like a first line %d%% of the time.\n",
|
||||
tprintf("# Indent of {} looks like a first line {}% of the time.\n",
|
||||
s.AlignTabs()[0].center, percent0firsts);
|
||||
tprintf("# Indent of %d looks like a first line %d%% of the time.\n",
|
||||
tprintf("# Indent of {} looks like a first line {}% of the time.\n",
|
||||
s.AlignTabs()[1].center, percent1firsts);
|
||||
s.PrintRows();
|
||||
}
|
||||
@ -2041,7 +2041,7 @@ static void StrongEvidenceClassify(int debug_level, std::vector<RowScratchRegist
|
||||
|
||||
if (debug_level > 1) {
|
||||
tprintf("#############################################\n");
|
||||
tprintf("# StrongEvidenceClassify( rows[%d:%d) )\n", row_start, row_end);
|
||||
tprintf("# StrongEvidenceClassify( rows[{}:{}) )\n", row_start, row_end);
|
||||
tprintf("#############################################\n");
|
||||
}
|
||||
|
||||
|
@ -881,7 +881,7 @@ bool Tesseract::word_dumper(PAGE_RES_IT *pr_it) {
|
||||
word_res->word->print();
|
||||
if (word_res->blamer_bundle != nullptr && wordrec_debug_blamer &&
|
||||
word_res->blamer_bundle->incorrect_result_reason() != IRR_CORRECT) {
|
||||
tprintf("Current blamer debug: %s\n", word_res->blamer_bundle->debug().c_str());
|
||||
tprintf("Current blamer debug: {}\n", word_res->blamer_bundle->debug().c_str());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ FILE *Tesseract::init_recog_training(const char *filename) {
|
||||
output_fname += ".txt";
|
||||
FILE *output_file = fopen(output_fname.c_str(), "a+");
|
||||
if (output_file == nullptr) {
|
||||
tprintf("Error: Could not open file %s\n", output_fname.c_str());
|
||||
tprintf("Error: Could not open file {}\n", output_fname.c_str());
|
||||
ASSERT_HOST(output_file);
|
||||
}
|
||||
return output_file;
|
||||
@ -94,7 +94,7 @@ void Tesseract::recog_training_segmented(const char *filename, PAGE_RES *page_re
|
||||
// ReadNextBox() will close box_file
|
||||
FILE *box_file = fopen(box_fname.c_str(), "r");
|
||||
if (box_file == nullptr) {
|
||||
tprintf("Error: Could not open file %s\n", box_fname.c_str());
|
||||
tprintf("Error: Could not open file {}\n", box_fname.c_str());
|
||||
ASSERT_HOST(box_file);
|
||||
}
|
||||
|
||||
@ -156,7 +156,7 @@ void Tesseract::recog_training_segmented(const char *filename, PAGE_RES *page_re
|
||||
"TODO(antonova): clean up recog_training_segmented; "
|
||||
" It examined only a small fraction of the ambigs image.\n");
|
||||
}
|
||||
tprintf("recog_training_segmented: examined %d / %d words.\n", examined_words, total_words);
|
||||
tprintf("recog_training_segmented: examined {} / {} words.\n", examined_words, total_words);
|
||||
}
|
||||
|
||||
// Helper prints the given set of blob choices.
|
||||
@ -214,7 +214,7 @@ void Tesseract::ambigs_classify_and_output(const char *label, PAGE_RES_IT *pr_it
|
||||
// Compute the number of unichars in the label.
|
||||
std::vector<UNICHAR_ID> encoding;
|
||||
if (!unicharset.encode_string(label, true, &encoding, nullptr, nullptr)) {
|
||||
tprintf("Not outputting illegal unichar %s\n", label);
|
||||
tprintf("Not outputting illegal unichar {}\n", label);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -541,7 +541,7 @@ bool ResultIterator::Next(PageIteratorLevel level) {
|
||||
at_beginning_of_minor_run_ = (word_indices[j - 1] == kMinorRunStart);
|
||||
// awesome, we move to word_indices[j]
|
||||
if (BidiDebug(3)) {
|
||||
tprintf("Next(RIL_WORD): %d -> %d\n", this_word_index, word_indices[j]);
|
||||
tprintf("Next(RIL_WORD): {} -> {}\n", this_word_index, word_indices[j]);
|
||||
}
|
||||
PageIterator::RestartRow();
|
||||
for (int k = 0; k < word_indices[j]; k++) {
|
||||
@ -552,7 +552,7 @@ bool ResultIterator::Next(PageIteratorLevel level) {
|
||||
}
|
||||
}
|
||||
if (BidiDebug(3)) {
|
||||
tprintf("Next(RIL_WORD): %d -> EOL\n", this_word_index);
|
||||
tprintf("Next(RIL_WORD): {} -> EOL\n", this_word_index);
|
||||
}
|
||||
// we're going off the end of the text line.
|
||||
return Next(RIL_TEXTLINE);
|
||||
@ -731,15 +731,13 @@ void ResultIterator::IterateAndAppendUTF8TextlineText(std::string *text) {
|
||||
std::vector<int> textline_order;
|
||||
std::vector<StrongScriptDirection> dirs;
|
||||
CalculateTextlineOrder(current_paragraph_is_ltr_, *this, &dirs, &textline_order);
|
||||
tprintf("Strong Script dirs [%p/P=%s]: ",
|
||||
static_cast<void *>(it_->row()),
|
||||
tprintf("Strong Script dirs [{}/P={}]: ", static_cast<void *>(it_->row()),
|
||||
current_paragraph_is_ltr_ ? "ltr" : "rtl");
|
||||
PrintScriptDirs(dirs);
|
||||
tprintf("Logical textline order [%p/P=%s]: ",
|
||||
static_cast<void *>(it_->row()),
|
||||
tprintf("Logical textline order [{}/P={}]: ", static_cast<void *>(it_->row()),
|
||||
current_paragraph_is_ltr_ ? "ltr" : "rtl");
|
||||
for (int i : textline_order) {
|
||||
tprintf("%d ", i);
|
||||
tprintf("{} ", i);
|
||||
}
|
||||
tprintf("\n");
|
||||
}
|
||||
@ -753,11 +751,11 @@ void ResultIterator::IterateAndAppendUTF8TextlineText(std::string *text) {
|
||||
AppendUTF8WordText(text);
|
||||
words_appended++;
|
||||
if (BidiDebug(2)) {
|
||||
tprintf("Num spaces=%d, text=%s\n", numSpaces, text->c_str());
|
||||
tprintf("Num spaces={}, text={}\n", numSpaces, *text);
|
||||
}
|
||||
} while (Next(RIL_WORD) && !IsAtBeginningOf(RIL_TEXTLINE));
|
||||
if (BidiDebug(1)) {
|
||||
tprintf("%d words printed\n", words_appended);
|
||||
tprintf("{} words printed\n", words_appended);
|
||||
}
|
||||
*text += line_separator_;
|
||||
// If we just finished a paragraph, add an extra newline.
|
||||
|
@ -169,13 +169,13 @@ bool Tesseract::SubAndSuperscriptFix(WERD_RES *word) {
|
||||
}
|
||||
|
||||
if (superscript_debug >= 1) {
|
||||
tprintf("Candidate for superscript detection: %s (",
|
||||
tprintf("Candidate for superscript detection: {} (",
|
||||
word->best_choice->unichar_string().c_str());
|
||||
if (num_leading || num_remainder_leading) {
|
||||
tprintf("%d.%d %s-leading ", num_leading, num_remainder_leading, leading_pos);
|
||||
tprintf("{}.{} {}-leading ", num_leading, num_remainder_leading, leading_pos);
|
||||
}
|
||||
if (num_trailing || num_remainder_trailing) {
|
||||
tprintf("%d.%d %s-trailing ", num_trailing, num_remainder_trailing, trailing_pos);
|
||||
tprintf("{}.{} {}-trailing ", num_trailing, num_remainder_trailing, trailing_pos);
|
||||
}
|
||||
tprintf(")\n");
|
||||
}
|
||||
@ -404,12 +404,12 @@ WERD_RES *Tesseract::TrySuperscriptSplits(int num_chopped_leading, float leading
|
||||
|
||||
// Adjust our expectations about the baseline for this prefix.
|
||||
if (superscript_debug >= 3) {
|
||||
tprintf(" recognizing first %d chopped blobs\n", num_chopped_leading);
|
||||
tprintf(" recognizing first {} chopped blobs\n", num_chopped_leading);
|
||||
}
|
||||
recog_word_recursive(prefix);
|
||||
if (superscript_debug >= 2) {
|
||||
tprintf(" The leading bits look like %s %s\n", ScriptPosToString(leading_pos),
|
||||
prefix->best_choice->unichar_string().c_str());
|
||||
tprintf(" The leading bits look like {} {}\n", ScriptPosToString(leading_pos),
|
||||
prefix->best_choice->unichar_string());
|
||||
}
|
||||
|
||||
// Restore the normal y-position penalties.
|
||||
@ -418,7 +418,7 @@ WERD_RES *Tesseract::TrySuperscriptSplits(int num_chopped_leading, float leading
|
||||
}
|
||||
|
||||
if (superscript_debug >= 3) {
|
||||
tprintf(" recognizing middle %d chopped blobs\n",
|
||||
tprintf(" recognizing middle {} chopped blobs\n",
|
||||
num_chopped - num_chopped_leading - num_chopped_trailing);
|
||||
}
|
||||
|
||||
@ -428,12 +428,12 @@ WERD_RES *Tesseract::TrySuperscriptSplits(int num_chopped_leading, float leading
|
||||
classify_integer_matcher_multiplier.set_value(0);
|
||||
|
||||
if (superscript_debug >= 3) {
|
||||
tprintf(" recognizing last %d chopped blobs\n", num_chopped_trailing);
|
||||
tprintf(" recognizing last {} chopped blobs\n", num_chopped_trailing);
|
||||
}
|
||||
recog_word_recursive(suffix);
|
||||
if (superscript_debug >= 2) {
|
||||
tprintf(" The trailing bits look like %s %s\n", ScriptPosToString(trailing_pos),
|
||||
suffix->best_choice->unichar_string().c_str());
|
||||
tprintf(" The trailing bits look like {} {}\n", ScriptPosToString(trailing_pos),
|
||||
suffix->best_choice->unichar_string());
|
||||
}
|
||||
|
||||
// Restore the normal y-position penalties.
|
||||
@ -476,8 +476,8 @@ WERD_RES *Tesseract::TrySuperscriptSplits(int num_chopped_leading, float leading
|
||||
}
|
||||
|
||||
if (superscript_debug >= 1) {
|
||||
tprintf("%s superscript fix: %s\n", *is_good ? "ACCEPT" : "REJECT",
|
||||
core->best_choice->unichar_string().c_str());
|
||||
tprintf("{} superscript fix: {}\n", *is_good ? "ACCEPT" : "REJECT",
|
||||
core->best_choice->unichar_string());
|
||||
}
|
||||
return core;
|
||||
}
|
||||
@ -550,14 +550,12 @@ bool Tesseract::BelievableSuperscript(bool debug, const WERD_RES &word, float ce
|
||||
}
|
||||
const char *char_str = wc.unicharset()->id_to_unichar(unichar_id);
|
||||
if (bad_certainty) {
|
||||
tprintf(
|
||||
" Rejecting: don't believe character %s with certainty %.2f "
|
||||
tprintf(" Rejecting: don't believe character {} with certainty %.2f "
|
||||
"which is less than threshold %.2f\n",
|
||||
char_str, char_certainty, certainty_threshold);
|
||||
}
|
||||
if (bad_height) {
|
||||
tprintf(
|
||||
" Rejecting: character %s seems too small @ %.2f versus "
|
||||
tprintf(" Rejecting: character {} seems too small @ %.2f versus "
|
||||
"expected %.2f\n",
|
||||
char_str, char_height, normal_height);
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ bool Tesseract::init_tesseract_lang_data(const std::string &arg0,
|
||||
// Initialize TessdataManager.
|
||||
std::string tessdata_path = language_data_path_prefix + kTrainedDataSuffix;
|
||||
if (!mgr->is_loaded() && !mgr->Init(tessdata_path.c_str())) {
|
||||
tprintf("Error opening data file %s\n", tessdata_path.c_str());
|
||||
tprintf("Error opening data file {}\n", tessdata_path.c_str());
|
||||
tprintf(
|
||||
"Please make sure the TESSDATA_PREFIX environment variable is set"
|
||||
" to your \"tessdata\" directory.\n");
|
||||
@ -131,7 +131,7 @@ bool Tesseract::init_tesseract_lang_data(const std::string &arg0,
|
||||
for (unsigned i = 0; i < vars_vec->size(); ++i) {
|
||||
if (!ParamUtils::SetParam((*vars_vec)[i].c_str(), (*vars_values)[i].c_str(),
|
||||
set_params_constraint, this->params())) {
|
||||
tprintf("Warning: The parameter '%s' was not found.\n", (*vars_vec)[i].c_str());
|
||||
tprintf("Warning: The parameter '{}' was not found.\n", (*vars_vec)[i].c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -142,7 +142,7 @@ bool Tesseract::init_tesseract_lang_data(const std::string &arg0,
|
||||
ParamUtils::PrintParams(params_file, this->params());
|
||||
fclose(params_file);
|
||||
} else {
|
||||
tprintf("Failed to open %s for writing params.\n", tessedit_write_params_to_file.c_str());
|
||||
tprintf("Failed to open {} for writing params.\n", tessedit_write_params_to_file.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@ -186,7 +186,7 @@ bool Tesseract::init_tesseract_lang_data(const std::string &arg0,
|
||||
else if (!mgr->GetComponent(TESSDATA_UNICHARSET, &fp) || !unicharset.load_from_file(&fp, false)) {
|
||||
tprintf(
|
||||
"Error: Tesseract (legacy) engine requested, but components are "
|
||||
"not present in %s!!\n",
|
||||
"not present in {}!!\n",
|
||||
tessdata_path.c_str());
|
||||
return false;
|
||||
}
|
||||
@ -327,7 +327,7 @@ int Tesseract::init_tesseract(const std::string &arg0, const std::string &textba
|
||||
|
||||
if (!loaded_primary) {
|
||||
if (result < 0) {
|
||||
tprintf("Failed loading language '%s'\n", lang_str);
|
||||
tprintf("Failed loading language '{}'\n", lang_str);
|
||||
} else {
|
||||
ParseLanguageString(tess_to_init->tessedit_load_sublangs, &langs_to_load,
|
||||
&langs_not_to_load);
|
||||
@ -335,7 +335,7 @@ int Tesseract::init_tesseract(const std::string &arg0, const std::string &textba
|
||||
}
|
||||
} else {
|
||||
if (result < 0) {
|
||||
tprintf("Failed loading language '%s'\n", lang_str);
|
||||
tprintf("Failed loading language '{}'\n", lang_str);
|
||||
delete tess_to_init;
|
||||
} else {
|
||||
sub_langs_.push_back(tess_to_init);
|
||||
|
@ -551,7 +551,7 @@ void BlamerBundle::LastChanceBlame(bool debug, WERD_RES *word) {
|
||||
word->blamer_bundle->SetBlame(IRR_UNKNOWN, debug_str, word->best_choice, debug);
|
||||
} else if (irr != IRR_CORRECT && correct) {
|
||||
if (debug) {
|
||||
tprintf("Corrected %s\n", word->blamer_bundle->debug_.c_str());
|
||||
tprintf("Corrected {}\n", word->blamer_bundle->debug_);
|
||||
}
|
||||
word->blamer_bundle->incorrect_result_reason_ = IRR_CORRECT;
|
||||
word->blamer_bundle->debug_ = "";
|
||||
@ -568,7 +568,7 @@ void BlamerBundle::SetMisAdaptionDebug(const WERD_CHOICE *best_choice, bool debu
|
||||
misadaption_debug_ += "): ";
|
||||
FillDebugString("", best_choice, misadaption_debug_);
|
||||
if (debug) {
|
||||
tprintf("%s\n", misadaption_debug_.c_str());
|
||||
tprintf("{}\n", misadaption_debug_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -299,7 +299,7 @@ private:
|
||||
debug_ += " to blame: ";
|
||||
FillDebugString(msg, choice, debug_);
|
||||
if (debug) {
|
||||
tprintf("SetBlame(): %s", debug_.c_str());
|
||||
tprintf("SetBlame(): {}", debug_);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,10 +41,9 @@ public:
|
||||
for (auto &it : cache_) {
|
||||
if (it.count > 0) {
|
||||
tprintf(
|
||||
"ObjectCache(%p)::~ObjectCache(): WARNING! LEAK! object %p "
|
||||
"still has count %d (id %s)\n",
|
||||
static_cast<void *>(this), static_cast<void *>(it.object),
|
||||
it.count, it.id.c_str());
|
||||
"ObjectCache({})::~ObjectCache(): WARNING! LEAK! object {} "
|
||||
"still has count {} (id {})\n",
|
||||
static_cast<void *>(this), static_cast<void *>(it.object), it.count, it.id.c_str());
|
||||
} else {
|
||||
delete it.object;
|
||||
it.object = nullptr;
|
||||
|
@ -26,7 +26,6 @@
|
||||
#include "params.h"
|
||||
|
||||
#include <climits> // for INT_MAX
|
||||
#include <cstdarg>
|
||||
#include <cstdio>
|
||||
|
||||
namespace tesseract {
|
||||
@ -38,7 +37,7 @@ INT_VAR(log_level, INT_MAX, "Logging level");
|
||||
static STRING_VAR(debug_file, "", "File to send tprintf output to");
|
||||
|
||||
// Trace printf
|
||||
void tprintf(const char *format, ...) {
|
||||
void vTessPrint(fmt::string_view format, fmt::format_args args) {
|
||||
const char *debug_file_name = debug_file.c_str();
|
||||
static FILE *debugfp = nullptr; // debug file
|
||||
|
||||
@ -62,14 +61,11 @@ void tprintf(const char *format, ...) {
|
||||
debugfp = nullptr;
|
||||
}
|
||||
|
||||
va_list args; // variable args
|
||||
va_start(args, format); // variable list
|
||||
if (debugfp != nullptr) {
|
||||
vfprintf(debugfp, format, args);
|
||||
fmt::vprint(debugfp, format, args);
|
||||
} else {
|
||||
vfprintf(stderr, format, args);
|
||||
fmt::vprint(stderr, format, args);
|
||||
}
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
} // namespace tesseract
|
||||
|
@ -19,22 +19,23 @@
|
||||
#ifndef TESSERACT_CCUTIL_TPRINTF_H
|
||||
#define TESSERACT_CCUTIL_TPRINTF_H
|
||||
|
||||
#include "params.h" // for BOOL_VAR_H
|
||||
#include "params.h" // for BOOL_VAR_H
|
||||
#include <fmt/format.h> // for fmt
|
||||
#include <tesseract/export.h> // for TESS_API
|
||||
|
||||
namespace tesseract {
|
||||
|
||||
#if !defined(__GNUC__) && !defined(__attribute__)
|
||||
# define __attribute__(attr) // compiler without support for __attribute__
|
||||
#endif
|
||||
|
||||
// Disable some log messages by setting log_level > 0.
|
||||
extern TESS_API INT_VAR_H(log_level);
|
||||
|
||||
// Helper function for tprintf.
|
||||
extern TESS_API void vTessPrint(fmt::string_view format, fmt::format_args args);
|
||||
|
||||
// Main logging function.
|
||||
extern TESS_API void tprintf( // Trace printf
|
||||
const char *format, ...) // Message
|
||||
__attribute__((format(printf, 1, 2)));
|
||||
template <typename S, typename... Args>
|
||||
void tprintf(const S *format, Args &&...args) {
|
||||
vTessPrint(format, fmt::make_args_checked<Args...>(format, args...));
|
||||
}
|
||||
|
||||
} // namespace tesseract
|
||||
|
||||
|
@ -253,7 +253,7 @@ void Dict::Load(const std::string &lang, TessdataManager *data_file) {
|
||||
}
|
||||
if (!trie_ptr->read_and_add_word_list(name.c_str(), getUnicharset(),
|
||||
Trie::RRP_REVERSE_IF_HAS_RTL)) {
|
||||
tprintf("Error: failed to load %s\n", name.c_str());
|
||||
tprintf("Error: failed to load {}\n", name);
|
||||
delete trie_ptr;
|
||||
} else {
|
||||
dawgs_.push_back(trie_ptr);
|
||||
@ -271,7 +271,7 @@ void Dict::Load(const std::string &lang, TessdataManager *data_file) {
|
||||
name += user_patterns_suffix;
|
||||
}
|
||||
if (!trie_ptr->read_pattern_list(name.c_str(), getUnicharset())) {
|
||||
tprintf("Error: failed to load %s\n", name.c_str());
|
||||
tprintf("Error: failed to load {}\n", name);
|
||||
delete trie_ptr;
|
||||
} else {
|
||||
dawgs_.push_back(trie_ptr);
|
||||
@ -326,7 +326,7 @@ void Dict::LoadLSTM(const std::string &lang, TessdataManager *data_file) {
|
||||
}
|
||||
if (!trie_ptr->read_and_add_word_list(name.c_str(), getUnicharset(),
|
||||
Trie::RRP_REVERSE_IF_HAS_RTL)) {
|
||||
tprintf("Error: failed to load %s\n", name.c_str());
|
||||
tprintf("Error: failed to load {}\n", name);
|
||||
delete trie_ptr;
|
||||
} else {
|
||||
dawgs_.push_back(trie_ptr);
|
||||
@ -344,7 +344,7 @@ void Dict::LoadLSTM(const std::string &lang, TessdataManager *data_file) {
|
||||
name += user_patterns_suffix;
|
||||
}
|
||||
if (!trie_ptr->read_pattern_list(name.c_str(), getUnicharset())) {
|
||||
tprintf("Error: failed to load %s\n", name.c_str());
|
||||
tprintf("Error: failed to load {}\n", name);
|
||||
delete trie_ptr;
|
||||
} else {
|
||||
dawgs_.push_back(trie_ptr);
|
||||
@ -411,8 +411,8 @@ int Dict::def_letter_is_okay(void *void_dawg_args, const UNICHARSET &unicharset,
|
||||
|
||||
if (dawg_debug_level >= 3) {
|
||||
tprintf(
|
||||
"def_letter_is_okay: current unichar=%s word_end=%d"
|
||||
" num active dawgs=%zu\n",
|
||||
"def_letter_is_okay: current unichar={} word_end={}"
|
||||
" num active dawgs={}\n",
|
||||
getUnicharset().debug_str(unichar_id).c_str(), word_end, dawg_args->active_dawgs->size());
|
||||
}
|
||||
|
||||
@ -456,7 +456,7 @@ int Dict::def_letter_is_okay(void *void_dawg_args, const UNICHARSET &unicharset,
|
||||
EDGE_REF dawg_edge = sdawg->edge_char_of(0, ch, word_end);
|
||||
if (dawg_edge != NO_EDGE) {
|
||||
if (dawg_debug_level >= 3) {
|
||||
tprintf("Letter found in dawg %d\n", sdawg_index);
|
||||
tprintf("Letter found in dawg {}\n", sdawg_index);
|
||||
}
|
||||
dawg_args->updated_dawgs->add_unique(
|
||||
DawgPosition(sdawg_index, dawg_edge, pos.punc_index, punc_transition_edge, false),
|
||||
@ -529,12 +529,12 @@ int Dict::def_letter_is_okay(void *void_dawg_args, const UNICHARSET &unicharset,
|
||||
: dawg->edge_char_of(node, char_for_dawg(unicharset, unichar_id, dawg), word_end);
|
||||
|
||||
if (dawg_debug_level >= 3) {
|
||||
tprintf("Active dawg: [%d, " REFFORMAT "] edge=" REFFORMAT "\n", pos.dawg_index, node, edge);
|
||||
tprintf("Active dawg: [{}, {}] edge={}\n", pos.dawg_index, node, edge);
|
||||
}
|
||||
|
||||
if (edge != NO_EDGE) { // the unichar was found in the current dawg
|
||||
if (dawg_debug_level >= 3) {
|
||||
tprintf("Letter found in dawg %d\n", pos.dawg_index);
|
||||
tprintf("Letter found in dawg {}\n", pos.dawg_index);
|
||||
}
|
||||
if (word_end && punc_dawg && !punc_dawg->end_of_word(pos.punc_ref)) {
|
||||
if (dawg_debug_level >= 3) {
|
||||
@ -563,7 +563,7 @@ int Dict::def_letter_is_okay(void *void_dawg_args, const UNICHARSET &unicharset,
|
||||
dawg_args->permuter = curr_perm;
|
||||
}
|
||||
if (dawg_debug_level >= 2) {
|
||||
tprintf("Returning %d for permuter code for this character.\n", dawg_args->permuter);
|
||||
tprintf("Returning {} for permuter code for this character.\n", dawg_args->permuter);
|
||||
}
|
||||
return dawg_args->permuter;
|
||||
}
|
||||
@ -587,9 +587,9 @@ void Dict::ProcessPatternEdges(const Dawg *dawg, const DawgPosition &pos, UNICHA
|
||||
continue;
|
||||
}
|
||||
if (dawg_debug_level >= 3) {
|
||||
tprintf("Pattern dawg: [%d, " REFFORMAT "] edge=" REFFORMAT "\n", pos.dawg_index, node,
|
||||
tprintf("Pattern dawg: [{}, {}] edge={}\n", pos.dawg_index, node,
|
||||
edge);
|
||||
tprintf("Letter found in pattern dawg %d\n", pos.dawg_index);
|
||||
tprintf("Letter found in pattern dawg {}\n", pos.dawg_index);
|
||||
}
|
||||
if (dawg->permuter() > *curr_perm) {
|
||||
*curr_perm = dawg->permuter();
|
||||
@ -612,7 +612,7 @@ void Dict::init_active_dawgs(DawgPositionVector *active_dawgs, bool ambigs_mode)
|
||||
*active_dawgs = hyphen_active_dawgs_;
|
||||
if (dawg_debug_level >= 3) {
|
||||
for (unsigned i = 0; i < hyphen_active_dawgs_.size(); ++i) {
|
||||
tprintf("Adding hyphen beginning dawg [%d, " REFFORMAT "]\n",
|
||||
tprintf("Adding hyphen beginning dawg [{}, {}]\n",
|
||||
hyphen_active_dawgs_[i].dawg_index, hyphen_active_dawgs_[i].dawg_ref);
|
||||
}
|
||||
}
|
||||
@ -632,12 +632,12 @@ void Dict::default_dawgs(DawgPositionVector *dawg_pos_vec, bool suppress_pattern
|
||||
if (dawg_ty == DAWG_TYPE_PUNCTUATION) {
|
||||
dawg_pos_vec->push_back(DawgPosition(-1, NO_EDGE, i, NO_EDGE, false));
|
||||
if (dawg_debug_level >= 3) {
|
||||
tprintf("Adding beginning punc dawg [%d, " REFFORMAT "]\n", i, NO_EDGE);
|
||||
tprintf("Adding beginning punc dawg [{}, {}]\n", i, NO_EDGE);
|
||||
}
|
||||
} else if (!punc_dawg_available || !subsumed_by_punc) {
|
||||
dawg_pos_vec->push_back(DawgPosition(i, NO_EDGE, -1, NO_EDGE, false));
|
||||
if (dawg_debug_level >= 3) {
|
||||
tprintf("Adding beginning dawg [%d, " REFFORMAT "]\n", i, NO_EDGE);
|
||||
tprintf("Adding beginning dawg [{}, {}]\n", i, NO_EDGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -698,7 +698,7 @@ void Dict::add_document_word(const WERD_CHOICE &best_choice) {
|
||||
filename += ".doc";
|
||||
FILE *doc_word_file = fopen(filename.c_str(), "a");
|
||||
if (doc_word_file == nullptr) {
|
||||
tprintf("Error: Could not open file %s\n", filename.c_str());
|
||||
tprintf("Error: Could not open file {}\n", filename);
|
||||
ASSERT_HOST(doc_word_file);
|
||||
}
|
||||
fprintf(doc_word_file, "%s\n", best_choice.debug_string().c_str());
|
||||
|
@ -707,8 +707,7 @@ bool ColumnFinder::AssignColumns(const PartSetVector &part_sets) {
|
||||
} else {
|
||||
column_set_costs[part_i][col_i] = INT32_MAX;
|
||||
if (debug) {
|
||||
tprintf("Set id %d did not match at y=%d, lineset =%p\n",
|
||||
col_i, part_i, static_cast<void *>(line_set));
|
||||
tprintf("Set id {} did not match at y={}, lineset ={}\n", col_i, part_i, static_cast<void *>(line_set));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1001,7 +1001,7 @@ void ColPartition::ComputeLimits() {
|
||||
}
|
||||
if (TabFind::WithinTestRegion(2, bounding_box_.left(),
|
||||
bounding_box_.bottom())) {
|
||||
tprintf("Recomputed box for partition %p\n", static_cast<void *>(this));
|
||||
tprintf("Recomputed box for partition {}\n", static_cast<void *>(this));
|
||||
Print();
|
||||
}
|
||||
}
|
||||
|
@ -490,10 +490,10 @@ void MergeInsignificantProtos(LIST ProtoList, const char *label, CLUSTERER *Clus
|
||||
}
|
||||
if (best_match != nullptr && !best_match->Significant) {
|
||||
if (debug) {
|
||||
auto bestMatchNumSamples = best_match->NumSamples;
|
||||
auto prototypeNumSamples = Prototype->NumSamples;
|
||||
tprintf("Merging red clusters (%d+%d) at %g,%g and %g,%g\n", bestMatchNumSamples,
|
||||
prototypeNumSamples, best_match->Mean[0], best_match->Mean[1], Prototype->Mean[0],
|
||||
auto BestMatchNumSamples = best_match->NumSamples;
|
||||
auto PrototypeNumSamples = Prototype->NumSamples;
|
||||
tprintf("Merging red clusters ({}+{}) at {},{} and {},{}\n", BestMatchNumSamples,
|
||||
PrototypeNumSamples, best_match->Mean[0], best_match->Mean[1], Prototype->Mean[0],
|
||||
Prototype->Mean[1]);
|
||||
}
|
||||
best_match->NumSamples =
|
||||
|
@ -77,9 +77,9 @@ static void DisplayProtoList(const char *ch, LIST protolist) {
|
||||
window->DrawTo((x + dx) * 256, (y + dy) * 256);
|
||||
auto prototypeNumSamples = prototype->NumSamples;
|
||||
if (prototype->Significant) {
|
||||
tprintf("Green proto at (%g,%g)+(%g,%g) %d samples\n", x, y, dx, dy, prototypeNumSamples);
|
||||
tprintf("Green proto at ({},{})+({},{}) {} samples\n", x, y, dx, dy, prototypeNumSamples);
|
||||
} else if (prototype->NumSamples > 0 && !prototype->Merged) {
|
||||
tprintf("Red proto at (%g,%g)+(%g,%g) %d samples\n", x, y, dx, dy, prototypeNumSamples);
|
||||
tprintf("Red proto at ({},{})+({},{}) {} samples\n", x, y, dx, dy, prototypeNumSamples);
|
||||
}
|
||||
}
|
||||
window->Update();
|
||||
|
@ -254,7 +254,7 @@ bool LanguageModel::UpdateState(bool just_classified, int curr_col, int curr_row
|
||||
tprintf("\nUpdateState: col=%d row=%d %s", curr_col, curr_row,
|
||||
just_classified ? "just_classified" : "");
|
||||
if (language_model_debug_level > 5) {
|
||||
tprintf("(parent=%p)\n", static_cast<void *>(parent_node));
|
||||
tprintf("(parent={})\n", static_cast<void *>(parent_node));
|
||||
} else {
|
||||
tprintf("\n");
|
||||
}
|
||||
@ -588,7 +588,7 @@ bool LanguageModel::AddViterbiStateEntry(LanguageModelFlagsType top_choice_flags
|
||||
dict_->getUnicharset().id_to_unichar(b->unichar_id()), b->rating(), b->certainty(),
|
||||
top_choice_flags);
|
||||
if (language_model_debug_level > 5) {
|
||||
tprintf(" parent_vse=%p\n", static_cast<void *>(parent_vse));
|
||||
tprintf(" parent_vse={}\n", static_cast<void *>(parent_vse));
|
||||
} else {
|
||||
tprintf("\n");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user