894 {
895 bool bol;
896
897
898 bool prev_fuzzy_sp;
899 bool prev_fuzzy_non;
900 uint8_t prev_blanks;
901 bool fuzzy_sp = false;
902 bool fuzzy_non = false;
903 uint8_t blanks = 0;
904 bool prev_gap_was_a_space = false;
905 bool break_at_next_gap = false;
907 C_OUTLINE_IT cout_it;
908 C_BLOB_LIST cblobs;
909 C_BLOB_IT cblob_it = &cblobs;
910 WERD_LIST words;
912 int32_t next_rep_char_word_right = INT32_MAX;
913 float repetition_spacing;
914 int32_t xstarts[2];
915 int32_t prev_x;
918 BLOBNBOX_IT box_it;
921 int16_t prev_gap = INT16_MAX;
922 int16_t current_gap = INT16_MAX;
923 int16_t next_gap = INT16_MAX;
924 int16_t prev_within_xht_gap = INT16_MAX;
925 int16_t current_within_xht_gap = INT16_MAX;
926 int16_t next_within_xht_gap = INT16_MAX;
927 int16_t word_count = 0;
928
929
931 if (!rep_char_it.empty ()) {
932 next_rep_char_word_right =
933 rep_char_it.data ()->bounding_box ().right ();
934 }
935
936 prev_x = -INT16_MAX;
937 cblob_it.set_to_list (&cblobs);
939
940 WERD_IT word_it(&words);
941 bol = true;
942 prev_blanks = 0;
943 prev_fuzzy_sp = false;
944 prev_fuzzy_non = false;
945 if (!box_it.empty ()) {
946 xstarts[0] = box_it.data ()->bounding_box ().left ();
947 if (xstarts[0] > next_rep_char_word_right) {
948
949 word = rep_char_it.extract ();
950 word_it.add_after_then_move (word);
951
953 bol = false;
955
959
960 repetition_spacing = find_mean_blob_spacing (word);
961 current_gap = box_it.data ()->bounding_box ().left () -
962 next_rep_char_word_right;
963 current_within_xht_gap = current_gap;
965 prev_blanks =
static_cast<uint8_t
>(floor (current_gap / row->
space_size));
966 if (prev_blanks < 1)
967 prev_blanks = 1;
968 }
969 else
970 prev_blanks = 0;
972 tprintf (
"Repch wd at BOL(%d, %d). rep spacing %5.2f; Rgap:%d ",
973 box_it.data ()->bounding_box ().left (),
974 box_it.data ()->bounding_box ().bottom (),
975 repetition_spacing, current_gap);
976 prev_fuzzy_sp = false;
977 prev_fuzzy_non = false;
978 if (rep_char_it.empty ()) {
979 next_rep_char_word_right = INT32_MAX;
980 }
981 else {
982 rep_char_it.forward ();
983 next_rep_char_word_right =
984 rep_char_it.data ()->bounding_box ().right ();
985 }
986 }
987
988 peek_at_next_gap(row,
989 box_it,
990 next_blob_box,
991 next_gap,
992 next_within_xht_gap);
993 do {
994 bblob = box_it.data ();
997 if (bblob->
cblob () !=
nullptr) {
998 cout_it.set_to_list (cblob_it.data ()->out_list ());
999 cout_it.move_to_last ();
1001 delete bblob->
cblob ();
1002 }
1003 } else {
1004 if (bblob->
cblob() !=
nullptr)
1005 cblob_it.add_after_then_move (bblob->
cblob ());
1006 prev_x = blob_box.
right ();
1007 }
1008 box_it.forward ();
1009 bblob = box_it.data ();
1011
1013
1014 prev_gap = current_gap;
1015 prev_within_xht_gap = current_within_xht_gap;
1016 prev_blob_box = next_blob_box;
1017 current_gap = next_gap;
1018 current_within_xht_gap = next_within_xht_gap;
1019 peek_at_next_gap(row,
1020 box_it,
1021 next_blob_box,
1022 next_gap,
1023 next_within_xht_gap);
1024
1025 int16_t prev_gap_arg = prev_gap;
1026 int16_t next_gap_arg = next_gap;
1028 prev_gap_arg = prev_within_xht_gap;
1029 next_gap_arg = next_within_xht_gap;
1030 }
1031
1032 if (blob_box.
left () > next_rep_char_word_right ||
1033 make_a_word_break(row, blob_box, prev_gap_arg, prev_blob_box,
1034 current_gap, current_within_xht_gap,
1035 next_blob_box, next_gap_arg,
1036 blanks, fuzzy_sp, fuzzy_non,
1037 prev_gap_was_a_space,
1038 break_at_next_gap) ||
1039 box_it.at_first()) {
1040
1041 word =
new WERD (&cblobs, prev_blanks,
nullptr);
1042 word_count++;
1043 word_it.add_after_then_move (word);
1044 if (bol) {
1046 bol = false;
1047 }
1048 if (prev_fuzzy_sp)
1049
1051 else if (prev_fuzzy_non)
1053
1054
1055 if (blob_box.
left () > next_rep_char_word_right) {
1056
1057 word = rep_char_it.extract ();
1058 word_it.add_after_then_move (word);
1059
1060
1061 repetition_spacing = find_mean_blob_spacing (word);
1063 current_within_xht_gap = current_gap;
1065 blanks =
1066 static_cast<uint8_t
>(floor (current_gap / row->
space_size));
1067 if (blanks < 1)
1068 blanks = 1;
1069 }
1070 else
1071 blanks = 0;
1074 ("Repch wd (%d,%d) rep gap %5.2f; Lgap:%d (%d blanks);",
1077 repetition_spacing, current_gap, blanks);
1079
1082
1083
1084 current_gap =
1085 blob_box.
left () - next_rep_char_word_right;
1087 blanks =
static_cast<uint8_t
>(current_gap / row->
space_size);
1088 if (blanks < 1)
1089 blanks = 1;
1090 }
1091 else
1092 blanks = 0;
1094 tprintf (
" Rgap:%d (%d blanks)\n",
1095 current_gap, blanks);
1096 fuzzy_sp = false;
1097 fuzzy_non = false;
1098
1099 if (rep_char_it.empty ()) {
1100 next_rep_char_word_right = INT32_MAX;
1101 }
1102 else {
1103 rep_char_it.forward ();
1104 next_rep_char_word_right =
1105 rep_char_it.data ()->bounding_box ().right ();
1106 }
1107 }
1108
1109 if (box_it.at_first () && rep_char_it.empty ()) {
1110
1112 xstarts[1] = prev_x;
1113 }
1114 else {
1115 prev_blanks = blanks;
1116 prev_fuzzy_sp = fuzzy_sp;
1117 prev_fuzzy_non = fuzzy_non;
1118 }
1119 }
1120 }
1121 }
1122 while (!box_it.at_first ());
1123
1124
1125 while (!rep_char_it.empty ()) {
1126 word = rep_char_it.extract ();
1127 word_it.add_after_then_move (word);
1128
1129
1130 repetition_spacing = find_mean_blob_spacing (word);
1133 blanks =
static_cast<uint8_t
>(floor (current_gap / row->
space_size));
1134 if (blanks < 1)
1135 blanks = 1;
1136 }
1137 else
1138 blanks = 0;
1141 "Repch wd at EOL (%d,%d). rep spacing %5.2f; Lgap:%d (%d blanks)\n",
1143 repetition_spacing, current_gap, blanks);
1145
1149 if (rep_char_it.empty ()) {
1150
1152 xstarts[1] = prev_x;
1153 }
1154 else {
1155 rep_char_it.forward ();
1156 }
1157 }
1158 real_row =
new ROW (row,
1160 word_it.set_to_list (real_row->
word_list ());
1161
1162 word_it.add_list_after (&words);
1164
1166 tprintf (
"Row: Made %d words in row ((%d,%d)(%d,%d))\n",
1167 word_count,
1172 }
1173 return real_row;
1174 }
1175 return nullptr;
1176}
@ W_FUZZY_NON
fuzzy nonspace
void set_blanks(uint8_t new_blanks)
TBOX bounding_box() const