Skip to content

Commit

Permalink
Merge pull request #1588 from ZaMaZaN4iK/fix_own_bool
Browse files Browse the repository at this point in the history
Use standard bool instead of BOOL8.
  • Loading branch information
egorpugin authored May 23, 2018
2 parents 78857ca + abca191 commit 5a56d0c
Show file tree
Hide file tree
Showing 66 changed files with 1,256 additions and 1,283 deletions.
20 changes: 10 additions & 10 deletions src/ccmain/adaptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
#endif

namespace tesseract {
BOOL8 Tesseract::word_adaptable( //should we adapt?
WERD_RES *word,
uint16_t mode) {
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",
word->best_choice == nullptr ? "" :
Expand All @@ -65,7 +65,7 @@ BOOL8 Tesseract::word_adaptable( //should we adapt?
*/
if (mode == 0) {
if (tessedit_adaption_debug) tprintf("adaption disabled\n");
return FALSE;
return false;
}

if (flags.bit (ADAPTABLE_WERD)) {
Expand All @@ -83,7 +83,7 @@ BOOL8 Tesseract::word_adaptable( //should we adapt?
}

if (!status) { // If not set then
return FALSE; // ignore other checks
return false; // ignore other checks
}

if (flags.bit (CHECK_DAWGS) &&
Expand All @@ -92,24 +92,24 @@ BOOL8 Tesseract::word_adaptable( //should we adapt?
(word->best_choice->permuter () != USER_DAWG_PERM) &&
(word->best_choice->permuter () != NUMBER_PERM)) {
if (tessedit_adaption_debug) tprintf("word not in dawgs\n");
return FALSE;
return false;
}

if (flags.bit (CHECK_ONE_ELL_CONFLICT) && one_ell_conflict (word, FALSE)) {
if (flags.bit (CHECK_ONE_ELL_CONFLICT) && one_ell_conflict (word, false)) {
if (tessedit_adaption_debug) tprintf("word has ell conflict\n");
return FALSE;
return false;
}

if (flags.bit (CHECK_SPACES) &&
(strchr(word->best_choice->unichar_string().string(), ' ') != nullptr)) {
if (tessedit_adaption_debug) tprintf("word contains spaces\n");
return FALSE;
return false;
}

if (flags.bit (CHECK_AMBIG_WERD) &&
word->best_choice->dangerous_ambig_found()) {
if (tessedit_adaption_debug) tprintf("word is ambiguous\n");
return FALSE;
return false;
}

if (tessedit_adaption_debug) {
Expand Down
26 changes: 13 additions & 13 deletions src/ccmain/control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void Tesseract::recog_pseudo_word(PAGE_RES* page_res,
*
* @param pr_it the page results iterator
*/
BOOL8 Tesseract::recog_interactive(PAGE_RES_IT* pr_it) {
bool Tesseract::recog_interactive(PAGE_RES_IT* pr_it) {
int16_t char_qual;
int16_t good_char_qual;

Expand All @@ -101,7 +101,7 @@ BOOL8 Tesseract::recog_interactive(PAGE_RES_IT* pr_it) {
word_blob_quality(word_res, pr_it->row()->row),
word_outline_errs(word_res), char_qual, good_char_qual);
}
return TRUE;
return true;
}

// Helper function to check for a target word and handle it appropriately.
Expand Down Expand Up @@ -674,7 +674,7 @@ void Tesseract::rejection_passes(PAGE_RES* page_res,
(stats_.doc_good_char_quality /
static_cast<float>(stats_.good_char_count)) : 0.0);
}
BOOL8 good_quality_doc =
bool good_quality_doc =
((page_res->rej_count / static_cast<float>(page_res->char_count)) <=
quality_rej_pc) &&
(stats_.doc_blob_quality / static_cast<float>(page_res->char_count) >=
Expand Down Expand Up @@ -1792,20 +1792,20 @@ ACCEPTABLE_WERD_TYPE Tesseract::acceptable_word_string(
return word_type;
}

BOOL8 Tesseract::check_debug_pt(WERD_RES *word, int location) {
BOOL8 show_map_detail = FALSE;
bool Tesseract::check_debug_pt(WERD_RES* word, int location) {
bool show_map_detail = false;
int16_t i;

if (!test_pt)
return FALSE;
return false;

tessedit_rejection_debug.set_value (FALSE);
debug_x_ht_level.set_value(0);

if (word->word->bounding_box ().contains (FCOORD (test_pt_x, test_pt_y))) {
if (word->word->bounding_box().contains(FCOORD (test_pt_x, test_pt_y))) {
if (location < 0)
return TRUE; // For breakpoint use
tessedit_rejection_debug.set_value (TRUE);
return true; // For breakpoint use
tessedit_rejection_debug.set_value(TRUE);
debug_x_ht_level.set_value(2);
tprintf ("\n\nTESTWD::");
switch (location) {
Expand All @@ -1827,7 +1827,7 @@ BOOL8 Tesseract::check_debug_pt(WERD_RES *word, int location) {
break;
case 50:
tprintf ("classify_word_pass2 - END");
show_map_detail = TRUE;
show_map_detail = true;
break;
case 60:
tprintf ("fixspace");
Expand All @@ -1849,7 +1849,7 @@ BOOL8 Tesseract::check_debug_pt(WERD_RES *word, int location) {
break;
case 120:
tprintf ("Write results pass");
show_map_detail = TRUE;
show_map_detail = true;
break;
}
if (word->best_choice != nullptr) {
Expand All @@ -1868,9 +1868,9 @@ BOOL8 Tesseract::check_debug_pt(WERD_RES *word, int location) {
}
tprintf ("Tess Accepted: %s\n", word->tess_accepted ? "TRUE" : "FALSE");
tprintf ("Done flag: %s\n\n", word->done ? "TRUE" : "FALSE");
return TRUE;
return true;
} else {
return FALSE;
return false;
}
}

Expand Down
76 changes: 38 additions & 38 deletions src/ccmain/docqual.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ int16_t Tesseract::count_outline_errs(char c, int16_t outline_count) {
}

void Tesseract::quality_based_rejection(PAGE_RES_IT &page_res_it,
BOOL8 good_quality_doc) {
bool good_quality_doc) {
if ((tessedit_good_quality_unrej && good_quality_doc))
unrej_good_quality_words(page_res_it);
doc_and_block_rejection(page_res_it, good_quality_doc);
Expand Down Expand Up @@ -232,14 +232,14 @@ void Tesseract::unrej_good_quality_words( //unreject potential

void Tesseract::doc_and_block_rejection( //reject big chunks
PAGE_RES_IT &page_res_it,
BOOL8 good_quality_doc) {
bool good_quality_doc) {
int16_t block_no = 0;
int16_t row_no = 0;
BLOCK_RES *current_block;
ROW_RES *current_row;

BOOL8 rej_word;
BOOL8 prev_word_rejected;
bool rej_word;
bool prev_word_rejected;
int16_t char_quality = 0;
int16_t accepted_char_quality;

Expand Down Expand Up @@ -273,7 +273,7 @@ void Tesseract::doc_and_block_rejection( //reject big chunks
block_no, current_block->char_count,
current_block->rej_count);
}
prev_word_rejected = FALSE;
prev_word_rejected = false;
while ((word = page_res_it.word()) != nullptr &&
(page_res_it.block() == current_block)) {
if (tessedit_preserve_blk_rej_perfect_wds) {
Expand All @@ -292,7 +292,7 @@ void Tesseract::doc_and_block_rejection( //reject big chunks
rej_word = char_quality != word->reject_map.length();
}
} else {
rej_word = TRUE;
rej_word = true;
}
if (rej_word) {
/*
Expand All @@ -304,7 +304,7 @@ void Tesseract::doc_and_block_rejection( //reject big chunks
prev_word_rejected &&
page_res_it.prev_row() == page_res_it.row() &&
word->word->space() == 1)
word->reject_spaces = TRUE;
word->reject_spaces = true;
word->reject_map.rej_word_block_rej();
}
prev_word_rejected = rej_word;
Expand Down Expand Up @@ -339,7 +339,7 @@ void Tesseract::doc_and_block_rejection( //reject big chunks
row_no, current_row->char_count,
current_row->rej_count);
}
prev_word_rejected = FALSE;
prev_word_rejected = false;
while ((word = page_res_it.word()) != nullptr &&
page_res_it.row () == current_row) {
/* Preserve words on good docs unless they are mostly rejected*/
Expand All @@ -363,7 +363,7 @@ void Tesseract::doc_and_block_rejection( //reject big chunks
rej_word = char_quality != word->reject_map.length();
}
} else {
rej_word = TRUE;
rej_word = true;
}
if (rej_word) {
/*
Expand All @@ -375,7 +375,7 @@ void Tesseract::doc_and_block_rejection( //reject big chunks
prev_word_rejected &&
page_res_it.prev_row() == page_res_it.row() &&
word->word->space () == 1)
word->reject_spaces = TRUE;
word->reject_spaces = true;
word->reject_map.rej_word_row_rej();
}
prev_word_rejected = rej_word;
Expand Down Expand Up @@ -411,16 +411,16 @@ void reject_whole_page(PAGE_RES_IT &page_res_it) {
page_res_it.forward ();
}
//whole page is rejected
page_res_it.page_res->rejected = TRUE;
page_res_it.page_res->rejected = true;
}

namespace tesseract {
void Tesseract::tilde_crunch(PAGE_RES_IT &page_res_it) {
WERD_RES *word;
GARBAGE_LEVEL garbage_level;
PAGE_RES_IT copy_it;
BOOL8 prev_potential_marked = FALSE;
BOOL8 found_terrible_word = FALSE;
bool prev_potential_marked = false;
bool found_terrible_word = false;
BOOL8 ok_dict_word;

page_res_it.restart_page();
Expand All @@ -439,13 +439,13 @@ void Tesseract::tilde_crunch(PAGE_RES_IT &page_res_it) {
word->merge_tess_fails();

if (word->reject_map.accept_count () != 0) {
found_terrible_word = FALSE;
found_terrible_word = false;
//Forget earlier potential crunches
prev_potential_marked = FALSE;
prev_potential_marked = false;
}
else {
ok_dict_word = safe_dict_word(word);
garbage_level = garbage_word (word, ok_dict_word);
garbage_level = garbage_word(word, ok_dict_word);

if ((garbage_level != G_NEVER_CRUNCH) &&
(terrible_word_crunch (word, garbage_level))) {
Expand All @@ -463,9 +463,9 @@ void Tesseract::tilde_crunch(PAGE_RES_IT &page_res_it) {
copy_it.word ()->unlv_crunch_mode = CR_KEEP_SPACE;
copy_it.forward ();
}
prev_potential_marked = FALSE;
prev_potential_marked = false;
}
found_terrible_word = TRUE;
found_terrible_word = true;
}
else if ((garbage_level != G_NEVER_CRUNCH) &&
(potential_word_crunch (word,
Expand All @@ -479,17 +479,17 @@ void Tesseract::tilde_crunch(PAGE_RES_IT &page_res_it) {
}
else if (!prev_potential_marked) {
copy_it = page_res_it;
prev_potential_marked = TRUE;
prev_potential_marked = true;
if (crunch_debug > 1) {
tprintf ("P3 CRUNCHING: \"%s\"\n",
word->best_choice->unichar_string().string());
}
}
}
else {
found_terrible_word = FALSE;
found_terrible_word = false;
//Forget earlier potential crunches
prev_potential_marked = FALSE;
prev_potential_marked = false;
if (crunch_debug > 2) {
tprintf ("NO CRUNCH: \"%s\"\n",
word->best_choice->unichar_string().string());
Expand All @@ -501,8 +501,8 @@ void Tesseract::tilde_crunch(PAGE_RES_IT &page_res_it) {
}


BOOL8 Tesseract::terrible_word_crunch(WERD_RES *word,
GARBAGE_LEVEL garbage_level) {
bool Tesseract::terrible_word_crunch(WERD_RES* word,
GARBAGE_LEVEL garbage_level) {
float rating_per_ch;
int adjusted_len;
int crunch_mode = 0;
Expand Down Expand Up @@ -533,20 +533,20 @@ BOOL8 Tesseract::terrible_word_crunch(WERD_RES *word,
tprintf ("Terrible_word_crunch (%d) on \"%s\"\n",
crunch_mode, word->best_choice->unichar_string().string());
}
return TRUE;
return true;
}
else
return FALSE;
return false;
}

BOOL8 Tesseract::potential_word_crunch(WERD_RES *word,
GARBAGE_LEVEL garbage_level,
BOOL8 ok_dict_word) {
bool Tesseract::potential_word_crunch(WERD_RES* word,
GARBAGE_LEVEL garbage_level,
bool ok_dict_word) {
float rating_per_ch;
int adjusted_len;
const char *str = word->best_choice->unichar_string().string();
const char *lengths = word->best_choice->unichar_lengths().string();
BOOL8 word_crunchable;
bool word_crunchable;
int poor_indicator_count = 0;

word_crunchable = !crunch_leave_accept_strings ||
Expand Down Expand Up @@ -590,8 +590,8 @@ BOOL8 Tesseract::potential_word_crunch(WERD_RES *word,
void Tesseract::tilde_delete(PAGE_RES_IT &page_res_it) {
WERD_RES *word;
PAGE_RES_IT copy_it;
BOOL8 deleting_from_bol = FALSE;
BOOL8 marked_delete_point = FALSE;
bool deleting_from_bol = false;
bool marked_delete_point = false;
int16_t debug_delete_mode;
CRUNCH_MODE delete_mode;
int16_t x_debug_delete_mode;
Expand All @@ -610,7 +610,7 @@ void Tesseract::tilde_delete(PAGE_RES_IT &page_res_it) {
word->best_choice->unichar_string().string());
}
word->unlv_crunch_mode = delete_mode;
deleting_from_bol = TRUE;
deleting_from_bol = true;
} else if (word->word->flag(W_EOL)) {
if (marked_delete_point) {
while (copy_it.word() != word) {
Expand All @@ -631,20 +631,20 @@ void Tesseract::tilde_delete(PAGE_RES_IT &page_res_it) {
word->best_choice->unichar_string().string());
}
word->unlv_crunch_mode = delete_mode;
deleting_from_bol = FALSE;
marked_delete_point = FALSE;
deleting_from_bol = false;
marked_delete_point = false;
}
else {
if (!marked_delete_point) {
copy_it = page_res_it;
marked_delete_point = TRUE;
marked_delete_point = true;
}
}
}
else {
deleting_from_bol = FALSE;
deleting_from_bol = false;
//Forget earlier potential crunches
marked_delete_point = FALSE;
marked_delete_point = false;
}
/*
The following step has been left till now as the tess fails are used to
Expand Down Expand Up @@ -975,7 +975,7 @@ int16_t Tesseract::failure_count(WERD_RES *word) {
}


BOOL8 Tesseract::noise_outlines(TWERD *word) {
bool Tesseract::noise_outlines(TWERD* word) {
TBOX box; // BB of outline
int16_t outline_count = 0;
int16_t small_outline_count = 0;
Expand Down
Loading

0 comments on commit 5a56d0c

Please sign in to comment.