21 #pragma warning(disable:4244) // Conversion warnings 22 #pragma warning(disable:4305) // int/float warnings 64 if (word->
done && (pass == 1) && (!word_from_dict || word_is_ambig) &&
69 if (word->
done && ((!word_from_dict &&
139 for (i = 0, offset = 0;
157 tprintf(
"BAD tessedit_reject_mode\n");
167 tprintf(
"Certainty: %f Rating: %f\n",
228 float bestgap = 0.0f;
231 BLOB_CHOICE_IT choice_it;
233 int blob_count = word->
length();
236 for (
int i = 0; i < blob_count; ++i) {
240 gapstart = ratings[0] - 1;
241 if (blob_count >= 3) {
242 for (
int index = 0; index < blob_count - 1; index++) {
243 if (ratings[index + 1] - ratings[index] > bestgap) {
244 bestgap = ratings[index + 1] - ratings[index];
246 gapstart = ratings[index];
250 threshold = gapstart + bestgap / 2;
273 for (
int blobindex = 0; blobindex < blobcount; blobindex++) {
279 word->
reject_map[blobindex].setrej_edge_char();
296 inT16 first_alphanum_index_;
297 inT16 first_alphanum_offset_;
300 BOOL8 non_conflict_set_char;
304 BOOL8 dict_perm_type;
310 word_len = strlen (lengths);
323 for (i = 0, offset = 0, non_conflict_set_char =
FALSE;
324 (i < word_len) && !non_conflict_set_char; offset += lengths[i++])
325 non_conflict_set_char =
329 if (!non_conflict_set_char) {
347 dict_word_ok = (dict_word_type > 0) &&
352 (dict_perm_type && dict_word_ok)) {
355 if (lengths[first_alphanum_index_] == 1 &&
356 word[first_alphanum_offset_] ==
'I') {
362 setrej_1Il_conflict();
371 if (lengths[first_alphanum_index_] == 1 &&
372 word[first_alphanum_offset_] ==
'l') {
378 setrej_1Il_conflict();
402 if (lengths[first_alphanum_index_] == 1 &&
403 word[first_alphanum_offset_] ==
'l') {
410 else if (lengths[first_alphanum_index_] == 1 &&
411 word[first_alphanum_offset_] ==
'I') {
430 for (i = 0, offset = 0; word[offset] !=
'\0';
432 if ((!allow_1s || (word[offset] !=
'1')) &&
435 word_res->
reject_map[i].setrej_1Il_conflict ();
452 setrej_1Il_conflict ();
470 const char *word_lengths) {
474 for (i = 0, offset = 0; word[offset] !=
'\0'; offset += word_lengths[i++]) {
483 const char *word_lengths) {
487 for (i = 0, offset = 0; word[offset] !=
'\0'; offset += word_lengths[i++]) {
496 const char *word_lengths) {
501 for (i = 0, offset = 0; word[offset] !=
'\0'; offset += word_lengths[i++]) {
510 const char *word_lengths) {
514 for (i = 0, offset = 0; word[offset] !=
'\0'; offset += word_lengths[i++]) {
516 (word_lengths[i] != 1 || word[offset] !=
'1'))
534 for (i = 0, offset = 0; i < word_len;
549 for (i = 0, offset = 0; i < word_len;
584 inT16 accepted_char_quality;
601 (char_quality == accepted_char_quality))
619 int prev_right = -9999;
629 for (i = 0; i < best_choice->
length() && i < num_blobs; ++i) {
632 if (i + 1 == num_blobs)
638 (out_box.
left() > prev_right) && (out_box.
right() < next_left)) {
639 aspect_ratio = out_box.
width() / (float) out_box.
height();
647 word_res->
reject_map[i].setrej_hyphen_accept();
654 else if (best_choice->
unichar_id(i) == unichar_dash) {
657 word_res->
reject_map[i].setrej_hyphen_accept();
666 prev_right = out_box.
right();
682 for (i = 0; i < best_choice->
length() && i < num_blobs; ++i) {
694 if (unichar_0 == INVALID_UNICHAR_ID ||
696 unichar_O == INVALID_UNICHAR_ID ||
700 for (i = 1; i < best_choice->
length(); ++i) {
701 if (best_choice->
unichar_id(i) == unichar_0 ||
704 if ((i+1) < best_choice->
length() &&
711 (i+1) < best_choice->
length() &&
714 (i+2) < best_choice->
length() &&
723 (((i+1) < best_choice->
length() &&
727 (i == best_choice->
length() - 1))) {
732 (i+1) < best_choice->
length() &&
738 (i+2) < best_choice->
length() &&
750 (i+2) < best_choice->
length() &&
760 (i+1) < best_choice->
length() &&
770 if (best_choice->
unichar_id(i-2) == unichar_O) {
773 while (i < best_choice->length() &&
786 return ch_set.
get_isupper(unichar_id) && !ch_set.
eq(unichar_id,
"O");
790 return ch_set.
get_isdigit(unichar_id) && !ch_set.
eq(unichar_id,
"0");
bool eq(UNICHAR_ID unichar_id, const char *const unichar_repr) const
double tessedit_upper_flip_hyphen
BOOL8 word_contains_non_1_digit(const char *word, const char *word_lengths)
BOOL8 non_0_digit(const UNICHARSET &ch_set, UNICHAR_ID unichar_id)
const int kBlnBaselineOffset
bool get_isalpha(UNICHAR_ID unichar_id) const
GenericVector< TBLOB * > blobs
void resize_no_init(int size)
const STRING & unichar_string() const
UNICHAR_ID unichar_id(int index) const
void dont_allow_1Il(WERD_RES *word)
double rej_whole_of_mostly_reject_word_fract
void initialise(inT16 length)
void rej_word_not_tess_accepted()
void set_unichar_id(UNICHAR_ID unichar_id, int index)
BOOL8 repeated_nonalphanum_wd(WERD_RES *word, ROW *row)
bool rej_use_tess_accepted
float compute_reject_threshold(WERD_CHOICE *word)
ACCEPTABLE_WERD_TYPE acceptable_word_string(const UNICHARSET &char_set, const char *s, const char *lengths)
WERD_CHOICE * best_choice
TBOX bounding_box() const
inT16 count_alphanums(const WERD_CHOICE &word)
void reject_poor_matches(WERD_RES *word)
bool rej_1Il_trust_permuter_type
tesseract::BoxWord * box_word
const char * string() const
void reject_edge_blobs(WERD_RES *word)
bool dangerous_ambig_found() const
void set_done(WERD_RES *word, inT16 pass)
void reject_blanks(WERD_RES *word)
inT16 first_alphanum_offset(const char *word, const char *word_lengths)
void rej_word_mostly_rej()
bool get_isupper(UNICHAR_ID unichar_id) const
void reject_I_1_L(WERD_RES *word)
void rej_word_small_xht()
bool tessedit_rejection_debug
BOOL8 non_O_upper(const UNICHARSET &ch_set, UNICHAR_ID unichar_id)
inT16 first_alphanum_index(const char *word, const char *word_lengths)
UNICHAR_ID TESS_API unichar_to_id(const char *const unichar_repr) const
void reject_mostly_rejects(WERD_RES *word)
void rej_word_bad_permuter()
double tessedit_lower_flip_hyphen
const UNICHARSET * uch_set
BOOL8 contains(const char c) const
const TBOX & BlobBox(int index) const
void flip_hyphens(WERD_RES *word)
int dict_word(const WERD_CHOICE &word)
void flip_0O(WERD_RES *word)
bool contains_unichar_id(UNICHAR_ID unichar_id) const
tesseract::Tesseract * tesseract
void make_reject_map(WERD_RES *word, ROW *row, inT16 pass)
bool rej_alphas_in_number_perm
inT16 safe_dict_word(const WERD_RES *werd_res)
void word_char_quality(WERD_RES *word, ROW *row, inT16 *match_count, inT16 *accepted_match_count)
void rej_word_contains_blanks()
char * ok_repeated_ch_non_alphanum_wds
const STRING & unichar_lengths() const
bool get_isdigit(UNICHAR_ID unichar_id) const
BOOL8 check_debug_pt(WERD_RES *word, int location)
bool get_enabled(UNICHAR_ID unichar_id) const
inT16 alpha_count(const char *word, const char *word_lengths)
int tessedit_image_border
BOOL8 one_ell_conflict(WERD_RES *word_res, BOOL8 update_map)
#define CLISTIZE(CLASSNAME)
TBOX bounding_box() const
char * conflict_set_I_l_1
bool rej_1Il_use_dict_word
CLISTIZEH(STRING) CLISTIZE(STRING) namespace tesseract