72 (*debug) +=
" Choice ";
75 (*debug) += choice_str;
92 BLOCK_LIST *the_block_list,
95 BLOCK_IT block_it(the_block_list);
96 BLOCK_RES_IT block_res_it(&block_res_list);
97 for (block_it.mark_cycle_pt();
98 !block_it.cycled_list(); block_it.forward()) {
99 block_res_it.add_to_end(
new BLOCK_RES(block_it.data()));
101 prev_word_best_choice = prev_word_best_choice_ptr;
111 ROW_IT row_it (the_block->
row_list ());
125 for (row_it.mark_cycle_pt(); !row_it.cycled_list(); row_it.forward()) {
126 row_res_it.add_to_end(
new ROW_RES(row_it.data()));
149 for (word_it.mark_cycle_pt(); !word_it.cycled_list(); word_it.forward()) {
150 word_res =
new WERD_RES(word_it.data());
160 copy_word =
new WERD;
162 *copy_word = *(word_it.data());
166 word_res_it.add_to_end(combo);
172 word_res_it.add_to_end(word_res);
289 if (use_body_size && row->
body_size() > 0.0f) {
319 const BLOCK* block) {
333 1.0f, 1.0f, 0.0f, 0.0f);
349 TOP_CHOICE_PERM, unicharset_in);
351 TOP_CHOICE_PERM, unicharset_in);
352 if (blob_count > 0) {
358 for (b_it.mark_cycle_pt(); !b_it.cycled_list(); b_it.forward()) {
359 TBOX box = b_it.data()->bounding_box();
362 -1, -1, -1, 0, 0,
false);
365 delete [] fake_choices;
388 topleft.
x = box.
left();
389 topleft.
y = box.
top();
394 TBOX norm_box(norm_topleft.
x, norm_botright.
y,
395 norm_botright.
x, norm_topleft.
y);
403 template<
class T>
static void MovePointerData(T** dest, T**src) {
465 for (
int i = 0; i < start; ++i)
468 if (prev_blob ==
NULL)
471 prev_blob->
next = copy_blob;
472 prev_blob = copy_blob;
488 for (
int i = 0; i < word_len; ++i) {
518 while (start < end &&
529 int *pstart,
int *pend)
const {
554 BLOB_CHOICE_LIST_CLIST* word_choices =
new BLOB_CHOICE_LIST_CLIST;
555 BLOB_CHOICE_LIST_C_IT bc_it(word_choices);
556 for (
int c = 0; c < blob_count; ++c) {
558 choices[c]->unichar_id(), 1,
559 choices[c]->rating(), choices[c]->certainty());
560 BLOB_CHOICE_LIST* choice_list =
new BLOB_CHOICE_LIST;
561 BLOB_CHOICE_IT choice_it(choice_list);
562 choice_it.add_after_then_move(choices[c]);
563 bc_it.add_after_then_move(choice_list);
591 BLOB_CHOICE_LIST_CLIST *blob_choices) {
592 bool modified =
false;
596 if (new_id != INVALID_UNICHAR_ID &&
613 BLOB_CHOICE_LIST_C_IT blob_choices_it(blob_choices);
614 for (
int j = 0; j < i; ++j)
615 blob_choices_it.forward();
616 BLOB_CHOICE_IT it1(blob_choices_it.data());
617 BLOB_CHOICE_LIST* target_choices = blob_choices_it.data_relative(1);
618 BLOB_CHOICE_IT it2(target_choices);
619 float certainty = it2.data()->certainty();
620 float rating = it2.data()->rating();
621 if (it1.data()->certainty() < certainty) {
622 certainty = it1.data()->certainty();
623 rating = it1.data()->rating();
624 target_choices = blob_choices_it.data();
625 blob_choices_it.forward();
627 delete blob_choices_it.extract();
644 static int is_simple_quote(
const char* signed_str,
int length) {
645 const unsigned char* str =
646 reinterpret_cast<const unsigned char*
>(signed_str);
648 return (length == 1 && (*str ==
'\'' || *str ==
'`')) ||
650 (length == 3 && ((*str == 0xe2 &&
651 *(str + 1) == 0x80 &&
652 *(str + 2) == 0x98) ||
654 *(str + 1) == 0x80 &&
655 *(str + 2) == 0x99)));
663 if (is_simple_quote(ch, strlen(ch)) &&
664 is_simple_quote(next_ch, strlen(next_ch)))
666 return INVALID_UNICHAR_ID;
686 if (strlen(ch) == 1 && strlen(next_ch) == 1 &&
687 (*ch ==
'-' || *ch ==
'~') && (*next_ch ==
'-' || *next_ch ==
'~'))
689 return INVALID_UNICHAR_ID;
717 return INVALID_UNICHAR_ID;
735 for (
int index = start; index < start + count - 1; ++index) {
846 return word_res == other.word_res &&
847 row_res == other.row_res &&
848 block_res == other.block_res;
853 if (other.block_res ==
NULL) {
855 if (block_res ==
NULL)
859 if (block_res ==
NULL) {
862 if (block_res == other.block_res) {
863 if (other.row_res ==
NULL || row_res ==
NULL) {
867 if (row_res == other.row_res) {
870 if (word_res == other.word_res) {
876 for (word_res_it.mark_cycle_pt(); !word_res_it.cycled_list();
877 word_res_it.forward()) {
878 if (word_res_it.data() == word_res) {
880 }
else if (word_res_it.data() == other.word_res) {
889 for (row_res_it.mark_cycle_pt(); !row_res_it.cycled_list();
890 row_res_it.forward()) {
891 if (row_res_it.data() == row_res) {
893 }
else if (row_res_it.data() == other.row_res) {
902 for (block_res_it.mark_cycle_pt();
903 !block_res_it.cycled_list(); block_res_it.forward()) {
904 if (block_res_it.data() == block_res) {
906 }
else if (block_res_it.data() == other.block_res) {
921 WERD_IT w_it(
row()->
row->word_list());
922 for (w_it.mark_cycle_pt(); !w_it.cycled_list(); w_it.forward()) {
924 if (word == word_res->
word)
928 w_it.add_before_then_move(new_word);
933 WERD_RES_IT wr_it(&
row()->word_res_list);
934 for (wr_it.mark_cycle_pt(); !wr_it.cycled_list(); wr_it.forward()) {
936 if (word == word_res)
940 wr_it.add_before_then_move(new_res);
941 if (wr_it.at_first()) {
958 WERD_IT w_it(
row()->
row->word_list());
959 for (w_it.mark_cycle_pt(); !w_it.cycled_list(); w_it.forward()) {
960 if (w_it.data() == word_res->
word) {
965 delete w_it.extract();
969 WERD_RES_IT wr_it(&
row()->word_res_list);
970 for (wr_it.mark_cycle_pt(); !wr_it.cycled_list(); wr_it.forward()) {
971 if (wr_it.data() == word_res) {
977 delete wr_it.extract();
989 block_res_it.mark_cycle_pt();
990 prev_block_res =
NULL;
992 prev_word_res =
NULL;
996 next_block_res =
NULL;
998 next_word_res =
NULL;
999 internal_forward(
true, empty_ok);
1000 return internal_forward(
false, empty_ok);
1010 void PAGE_RES_IT::ResetWordIterator() {
1011 if (row_res == next_row_res) {
1014 word_res_it.move_to_first();
1015 word_res_it.mark_cycle_pt();
1016 while (!word_res_it.cycled_list() && word_res_it.data() != next_word_res)
1017 word_res_it.forward();
1019 word_res_it.forward();
1038 WERD_RES *PAGE_RES_IT::internal_forward(
bool new_block,
bool empty_ok) {
1039 bool new_row =
false;
1041 prev_block_res = block_res;
1042 prev_row_res = row_res;
1043 prev_word_res = word_res;
1044 block_res = next_block_res;
1045 row_res = next_row_res;
1046 word_res = next_word_res;
1047 next_block_res =
NULL;
1048 next_row_res =
NULL;
1049 next_word_res =
NULL;
1051 while (!block_res_it.cycled_list()) {
1054 row_res_it.set_to_list(&block_res_it.data()->row_res_list);
1055 row_res_it.mark_cycle_pt();
1056 if (row_res_it.empty() && empty_ok) {
1057 next_block_res = block_res_it.data();
1062 while (!row_res_it.cycled_list()) {
1065 word_res_it.set_to_list(&row_res_it.data()->word_res_list);
1066 word_res_it.mark_cycle_pt();
1069 while (!word_res_it.cycled_list() && word_res_it.data()->part_of_combo)
1070 word_res_it.forward();
1071 if (!word_res_it.cycled_list()) {
1072 next_block_res = block_res_it.data();
1073 next_row_res = row_res_it.data();
1074 next_word_res = word_res_it.data();
1075 word_res_it.forward();
1079 row_res_it.forward();
1083 block_res_it.forward();
1102 if (!row)
return NULL;
1116 while (block_res == next_block_res &&
1117 (next_row_res !=
NULL && next_row_res->
row !=
NULL &&
1119 internal_forward(
false,
true);
1121 return internal_forward(
false,
true);
1131 while (block_res == next_block_res) {
1132 internal_forward(
false,
true);
1134 return internal_forward(
false,
true);
1138 inT16 chars_in_word;
1139 inT16 rejects_in_word = 0;
1149 block_res->
rej_count += rejects_in_word;
1151 if (chars_in_word == rejects_in_word)